开发者

jquery live click behaviour in 1.4.4

开发者 https://www.devze.com 2023-02-06 04:16 出处:网络
i m using jquery ui tabs and inside the tabs i m calling jquery live function using a code now in 1.4.2 i did not had to call the line

i m using jquery ui tabs and inside the tabs i m calling jquery live function using a code

now in 1.4.2 i did not had to call the line

  $('.show_comment').die('click');

but in jquery 1.4.4 i have开发者_开发知识库 to call as the "live" function is fired twice on revisiting a tab ( n+1 times on visiting a tab n times)

in jquery 1.4.2 it was fired only once...

as i have long codes i have to add many "die statements"

Any other work around for not adding die calls

The code...

      $('#tabs').tabs(
{
    load: function(e, ui) 
    {
        $('.show_comment').die('click');
        if ($('#tabs-2').tabs('option','selected') == 0)
        {
            $('.show_comment').live('click' , function() {
                console.log( $(this).text() );
                /*
                var p = $(this).parents().filter(':eq(6)');
                var bar_cls = p.attr('class');

                $("ol#update li." + bar_cls +" ol li").toggle('fast');
                */

                /*$("ol#update li." + bar_cls +" ol li").children(".nli_comment").corner();*/
                return false;
            });
        }
    }
,
selected: 1,
fx:{height: 'toggle', duration: 'fast'},
spinner: '<em>Loading...</em>' ,
collapsible: true
});

Any help

thanks


Use .bind instead. I take it that your tab content is loaded in from an ajax source? If so, then binding on the tabsload event will result in a new handler getting attached each time the tab is loaded, so it makes sense that you need to call die() beforehand.

Using .bind means that the click handler attached to .show_comment will naturally die when you load another tab, and will get reattached when #tabs-2 is loaded again.

0

精彩评论

暂无评论...
验证码 换一张
取 消