I bind via live operator a click function to a li-element:
$(".UListView li input.iconbutton.click").live("click", function(e){
e.preventDefault();
[...]
$.get("ajax/categorylist.php?appendcategories=true&parentcat="+currentid+"&side="+side, function(data){
[...]
});
});
In nearly 90% of the cases it is executed one time and everything is alright. But sometimes the ajax request is executed 2 or even more times:
This is the output from firebug: (Executed two times)
jquery.min.js (Zeile 4)
GET htt-p://localhost/request.php?.... 200 OK 11ms
jquery.min.js (Zeile 4)
GET htt-p://localhost/request.php?.... 200 OK 19ms
This totaly breaks my layout, because all the elements are added in the worst case 6x to the DOM.
Does anybody know what is the reason for this behaviour? Or good idea to fix the "adding to DOM" code is executed multiple times.
add e.stopPropagation();
to your code as well as return false;
before the end of click event