Brice Burgess schrieb:
> Klaus Hartl wrote:
>> That would be done like:
>>
>> $('#container>ul>li>a:eq(2)').click(function() {
>>      if (formIsValid()) {
>>          $('#container-1').enableTab(2).triggerTab(2);
>>      }
>>      return false;
>> });
>>
>> Well, not exactly. The problem is that you're submittig a form, and that 
>> is going to be asynchronous I assume... That's totally not supported for 
>> onClick, because I just cannot stop execution of the rest of the script 
>> while waiting for the response of the form submit.
>>   
> You're right that wouldn't work.. that's why I would like to cancel tab 
> activation if onClick returns false. This way I can do;
> 
> 
> $(container).tabs({remote: true, onClick: submitForm});
> 
> var clickedTab = false;
> 
> function submitForm(tab, content, oldContent) {
>     // pseudo code...
> 
>   clickedTab = index_of_tab;
> 
>     $(form,oldContent).submit();
>     //  NOTE; the forms plugin is attached to the form, and 
> asynchronously submits it. Upon form return, successCallback is called.
> 
>    // cancel tab activation -- *KEY* behavior
>    return false;
> }
> 
> function successCallback() {
>   if(form passed server side validation)
>     $(container).triggerTab(clickedTab);
>   else
>     ... (form did not pass server side validation)
> }

But that could be done like that:

$('#tabs').tabs({ remote: true, disabled: [2, 3] });
$('#tabs>ul>li>a:eq(2)').click(function() {
     submitForm();
});

// callback for submit form
function callback(result) {
     if (result == form passed server side validation) {
         $('#tabs').enableTab(2).triggerTab(2);
     }
}

Well, anyway, I'll implement your request if it's possible...


-- Klaus


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to