Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Droppable and sortable functions on dynamically created elements not working

Stuck with this issue for the past 2 days :-( Trying to create draggable sortable list with dynamically added groups. Was able to create containers, but divs cant be dropped to these containers.. Can somebody point out where I am doing it wrong, I know that it has to be assigned to a variable, even tried that, still now working.. Fiddle is as follows..

http://jsfiddle.net/Sullan/mLHJW/

like image 692
Sullan Avatar asked Jan 18 '12 03:01

Sullan


2 Answers

if dynmmcally created elements not working try using on in jquery version 1.7 . if you are using less than that , like 1.6 , 1.5 or something you can use live

example

$("p").on("click", function(){
alert( $(this).text() );
});

or

$("p").live("click", function(){
alert( $(this).text() );
});

insted of

$("p").click( function(){
alert( $(this).text() );
});

on ad live wil be added to the dynamically created elements

http://api.jquery.com/on/

http://api.jquery.com/live/

like image 199
Kanishka Panamaldeniya Avatar answered Oct 02 '22 16:10

Kanishka Panamaldeniya


Just repeated the call within the button click.. not sure whether its the right way.. but works out fine...

http://jsfiddle.net/Sullan/mLHJW/1/

like image 39
Sullan Avatar answered Oct 02 '22 15:10

Sullan