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..
在过去的两天里,我一直在关注这个问题:-(尝试用动态添加的组创建可拖动的可排序列表)。我们可以创建容器,但是不能将div标签放到这些容器中。有人能指出我哪里做错了吗,我知道它必须被分配给一个变量,甚至尝试过,现在还在工作。小提琴如下. .
http://jsfiddle.net/Sullan/mLHJW/
http://jsfiddle.net/Sullan/mLHJW/
3 个解决方案
#1
5
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
如果dynmly创建的元素不能工作,请在jquery版本1.7中尝试使用。如果你用的比这个要少,比如1。6,1。5或者其他你可以用的东西
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
在ad live上,将添加到动态创建的元素中
http://api.jquery.com/on/
http://api.jquery.com/live/
#2
5
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/
http://jsfiddle.net/Sullan/mLHJW/1/
#3
2
try using this plugin http://docs.jquery.com/Plugins/livequery#Download
尝试使用这个插件http://docs.jquery.com/Plugins/livequery#下载
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')
});
});
#1
5
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
如果dynmly创建的元素不能工作,请在jquery版本1.7中尝试使用。如果你用的比这个要少,比如1。6,1。5或者其他你可以用的东西
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
在ad live上,将添加到动态创建的元素中
http://api.jquery.com/on/
http://api.jquery.com/live/
#2
5
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/
http://jsfiddle.net/Sullan/mLHJW/1/
#3
2
try using this plugin http://docs.jquery.com/Plugins/livequery#Download
尝试使用这个插件http://docs.jquery.com/Plugins/livequery#下载
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')
});
});