Brice Burgess schrieb:
> Klaus Hartl wrote:
>>> $('#mailing').enableTab(1).triggerTab(1); does not work, for instance.
>>>
>> Brice, I think something else went wrong there. On a simple test page
>> that works fine for me:
>> http://stilbuero.de/jquery/tabs/test.html
>>
>> Maybe you can show some more code here...
>>
> Klaus, did you try it w/ remote: true; && disabled tabs? Something like;
>
> <div id="mailing">
> <ul class="anchors">
> <li class="tabs-disabled"><a
> href="mailing/composition.php">{t}Composition{/t}</a></li>
> <li class="tabs-disabled"><a
> href="mailing/template.php">{t}Template{/t}</a></li>
> <li class="tabs-disabled"><a
> href="mailing/message.php">{t}Message{/t}</a></li>
> <li class="tabs-disabled"><a
> href="mailing/preview.php">{t}Preview{/t}</a></li>
> </ul>
> </div>
>
> <script type="text/javascript">
>
> $().ready(function(){
> $('#mailing').tabs({remote: true}});
> $('#mailing').enableTab(1).triggerTab(1);
> });
> </script>
The second example on the test page is done with remote: true. However I
disabled the tabs like:
$('#container-9').tabs({remote: true, disabled: [2, 3]});
> (( remember, I need to submit a form on tab click, and only activate the
> clicked tab IF the form returns valid (server side validation ))
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.
>>> I think the easiest/less ugly way to go about this is to intercept
>>> (cancel) the onClick event if it returns false. This way I could submit
>>> the form in the onClick and return false. When the form response comes
>>> back, I can then either trigger the tab, or alert the error message.
>>>
>>> Does this make any sense?
>>>
>> I'm not overall sure. Would that be expected behavior? Implementation
>> wouldn't be to difficult, so I could do that, but maybe we can work out
>> a solution with the existing code...
>>
> The behavior does not seem obscure to me, and seems to offer more
> function than none at all -- in fact, it follows the flow of the general
> event system. Like I said, I could not come up with a more elegant
> solution... although look forward to any of your suggestions.
You are making a good point here, "more function than none at all". But
even if I implement that, it would be useless for you, for the reason I
described above. Or are you making synchronous requests?
A solution to your problem would be to call
$('#container-1').enableTab(2).triggerTab(2);
in the callback of the Ajax request, depending on what is returned, as
far as I understand.
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/