开发者

Apply jqueryUI interaction attributes to newly added DOM elements?

开发者 https://www.devze.com 2023-04-07 01:44 出处:网络
So I start off with an element of class=\"list\" that are defined as .sortable.Now if I cr开发者_运维知识库eate another element of class=\"list\" via jquery, it does not inherit the same definition th

So I start off with an element of class="list" that are defined as .sortable. Now if I cr开发者_运维知识库eate another element of class="list" via jquery, it does not inherit the same definition that I had already defined.

Now, I got around that by throwing the definition into a function and then call the function upon initial load and as well as every time I add a new element. Is this the best method? Or is there a more appropriate method of doing this?

http://jsfiddle.net/S24d4/11/


You probably want jQuery's .live() function. This will bind things to DOM elements added later.

0

精彩评论

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