开发者

Clone all 'observe' of a cloned element using Prototype

I have a sortable list (done using prototype and scriptaculous): y开发者_如何学Pythonou can sort its elements or drag them into another list.

When I drop the element (let's call it ELEMENT_1) of a list into another one what I do is a 'clone' of the dropped element and then I insert (appendChild) it into the new list.

ELEMENT1 had some 'observe' (clicking on it do something, double-clicking on it do something else) that are of course lost when I do the cloning.. I want the cloned element to have the same 'observe' of ELEMENT1.

How can I do that?

Thanks in advance


Observe the lists instead of their items and allow event bubbling to do the work for you.

$('list1','list2').invoke('on', 'click', 'li', function(event, element){
    // "this" is either list1 or list2
    // "element" is the list item
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜