tags - Jquery Mixitup plugin help prevent handlers being destroyed -


update: error in console.

uncaught exception: query function not defined select2 undefined

i using code allow users add tags images. works fine. problem running when images sorted(using mixitup.io plugin). before sorting, script works perfect(popup,edit,save,db update). after user clicks few of sort buttons, script stops responding , popup not fire.

please have below , me find problem is. :)

working code:

$('.tags').editable({      placement: 'top',     select2: {         tags: ['cookies', 'pie','cake'],         tokenseparators: [","]     },     display: function(value) {         $.each(value,function(i){            value[i] = "<span class='tagbox'>" + $('<p>' + value[i] + '</p>').text() + "</span>";         });         $(this).html(value.join(" "));     } }); 

to prevent mixitup.io plugin destroying handler, says use "delegate()". have tried kinds of different code/combos, no luck. here last attempt

$('#content').delegate( ".tags", "click", function() {   $('.tags').editable({      placement: 'top',     select2: {         tags: ['cookies', 'pie','cake'],         tokenseparators: [","]     },     display: function(value) {         $.each(value,function(i){            value[i] = "<span class='tagbox'>" + $('<p>' + value[i] + '</p>').text() + "</span>";         });         $(this).html(value.join(" "));     } });  }); 

waht know mixitup sort function destroies element binded events to elements lost.

the quick solution is: dont bind events elements!

for example have link in items binded click event on them.

$("a.clickable").on("click",function(){//....}); 

so said bind click event parent element body:

$("body").on("click",'a.clickable' ,function(){//....}); // tested solution. 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -