events - jQuery - off() and on() inside handler function -
i use jquery .on()
method attach event handler function div elements inside div element id "w1" inside event handler function want detach event before ajax call , attach again after ajax complete. here simple script
$(document).on("click", "#w1 div", function() { $(document).off("click","#w1 div"); $.ajax({ type: "post", cache: false, url: "chtr.py", complete: function(){ $(document).on("click","#w1 div"); // not work } }); });
i don't know how reattach event handler function elements again.
if want attach same function, you'll need make named function can refer again (or assign variable):
$(document).on("click", "#w1 div", clickhandler); function clickhandler() { $(document).off("click","#w1 div"); $.ajax({ type: post, cache: false, url: "chtr.py", complete: function(){ $(document).on("click","#w1 div", clickhandler); } }); }
Comments
Post a Comment