我是附JQuery UI Selectable
到UL element
。但li item
这里面是动态创建当然。而且,我不能让them.So的选择,如何安装plugin's function to dynamic created elements in JQuery
!?如何将插件的功能附加到JQuery中的动态创建元素?
E.g:
<ul id="selectable">
<li class="dataItem">item dynamic created here but you can't select me</li>
</ul>
[更新]
jQuery代码:
$("#selectable").selectable();
,并在那里我用delegate
或live
!?
的delegate
和live
用法是将事件绑定这样的方式:
$('#selectable').delegate('li','click',function(){
// do something here
});
但selectable plugin's events
是:
Supply a callback function to handle the selected event as an init option.
$(".selectable").selectable({
selected: function(event, ui) { ... }
});
和新添加的项目没有拿到selectable plugin's
状态如:
ui-selectee
So,should I re-attach the plugin at every time when a new item added!?
谢谢你非常感谢!
已更新的答案... – Reigel 2011-02-15 04:03:55