Klaus Hartl wrote:
> Brice Burgess schrieb:
>
>> 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,
I think your method is possible, and one I originally tried before
running into the $(e).enableTab(1).triggerTab(1); bug which prompted my
post (more regarding bug below). However, I also think that this method
will end up being much more complicated (vs. onClick returning false to
cancel loading of tab) as it needs to account for all the logic of
enabling/disabling the tabs as well as CSS styling && loosing the
ability to actually disable a tab (stylistically) without adding another
layer of kludge ;)
I will be extremely grateful if you are able to bring the canceling
functionality to the onClick function. I took a quick peak and realized
it was not as simple as;
if (typeof onClick == 'function') { if (!onClick) return false; }
due to that setTimeout function....
Let me know how it goes, I'll have more time tomorrow to take a stab
at this.
Also, regarding the supposed .enableTab(#).triggerTab(#) bug; I found
it to be limited to the initial tab (index 1) Given:
<div id="mailing">
<ul class="anchors">
<li class="tabs-disabled"><a
href="mailing/composition.php">{t}Setup{/t}</a></li>
<li class="tabs-disabled"><a
href="mailing/template.php">{t}Templates{/t}</a></li>...
</ul>
</div>
<script type="text/javascript">
$().ready(function(){
$('#mailing').tabs({remote: true});
$('#mailing').enableTab(1).triggerTab(1); /* does not open tab 1 */
// $('#mailing').enableTab(2).triggerTab(2); /* works (opens tab 2) */
});
</script>
Anyhow, I do appreciate all your efforts man! Sorry for being a pain.
As ever,
~ Brice
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/