我是附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