我被附加JQuery UI Selectable
到一个UL element
。但是li item
里面是动态创建的。当然,我无法选择它们。那么,如何附加plugin's function to dynamic created elements in JQuery
!?
例如:
<ul id="selectable">
<li class="dataItem">item dynamic created here but you can't select me</li>
</ul>
[更新]
jQuery代码:
$( "#selectable" ).selectable();
我在哪里使用delegate
或live
!?
delegate
and的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!?
非常感谢你!!