Question

Can someone help me fix this code, please? What I want is to block the live ('click') function until the sliddingright function is done.

('li.menu-item').live('click', function(event){
    if( !$(this).is(':animated')) 
    {
    sliddingright(page_id_target_right,previous_right_old,previous_right,next_right,pages_numbers);
    }
});
Was it helpful?

Solution

Just add a return statement to your slidingright function that returns 'standby' once the function has completed its task, save it and check its value next time 'click' is called.

Like so :

var state = 'standby';
('li.menu-item').live('click', function(event){
    if( !$(this).is(':animated') && state == 'standby' ) 
    {
        state = 'processing';
        state = sliddingright(page_id_target_right,previous_right_old,previous_right,next_right,pages_numbers);
    }
});

OTHER TIPS

Try:

clickMe = function() {
$('li.menu-item').live('click', function(event) {
    $('li.menu-item').off('click');
    sliddingright(page_id_target_right, previous_right_old, previous_right, next_right, pages_numbers);
});
    $('li.menu-item').on("click", clickMe);
};​
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top