jquery - Rebound same function -


i want bind element function via live() method. function excecutes fine first time. think have unbind element events , rebound same function don't know how it!

here code:

var temp = function() {     var htmlex = "lorem ipsum dolor sit amet, consectetur adipiscing elit.";      $('#template_loading').fadein();     $('#template_loading').queue(function() {         $('#tp_prev').html(htmlex);         $('#template_container').removeclass("cur_temp");         $('#template_container').addclass("cur_prev");         $('#template_container').animate({"margin-left" : "0"}, 400, 'easeoutexpo');             $('#template_container').queue(function() {             $('#template_loading').fadeout();                            $('#tp_cur').empty();                            $('#template_container').removeclass("cur_prev");             $('#template_container').addclass("cur_temp");               $('#tp_prev').empty();                           $('#tp_cur').html(htmlex);             $('#tp_cur').queue(function() {                 $('#prev.pers_arrow').die();                 $('#prev.pers_arrow').live("click", temp);                 $(this).dequeue();             });             $(this).dequeue();         });         $(this).dequeue();     }); };  $('#prev.pers_arrow').live("click", temp);  

the first: never, ever, ever that.

you have cache data , don't jump time dom!!!

second: in opinion live deprecated -so can use on , off

try that:

var prev=$("#prev"); var pers_arrow=".pers_arrow";     var temp = function() {     var htmlex = "lorem ipsum dolor sit amet, consectetur adipiscing elit.";     var template_loading=$('#template_loading');      template_loading         .fadein()         .queue(function() {             $('#tp_prev').html(htmlex);             var template_container=$('#template_container');             template_container                 .removeclass("cur_temp")                 .addclass("cur_prev")                 .animate({"margin-left" : "0"}, 400, 'easeoutexpo')                 .queue(function() {                     template_loading.fadeout();                                     template_container.removeclass("cur_prev").addclass("cur_temp");                       $('#tp_prev').empty();                         //you can don't use - because .html() method clean container                              //$('#tp_cur').empty();                           $('#tp_cur').html(htmlex).queue(function() {                         prev.off("click",pers_arrow,temp).on("click",pers_arrow,temp);                         $(this).dequeue();                     });                     $(this).dequeue();                 });             $(this).dequeue();         }); }; prev.off("click",pers_arrow,temp).on("click",pers_arrow,temp) 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -