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..
3 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
Comments
Just repeated the call within the button click.. not sure whether its the right way.. but works out fine...
Comments
try using this plugin http://docs.jquery.com/Plugins/livequery#Download
once you include it just use it like this (example from your code):
var test = $('ul.itemsList').livequery(function(){
$(this).sortable({
connectWith: $('.itemsList, .itemsList li')
});
});