clone(true) should do the trick. Though before there was a bug with this function where the events would not be cloned (in IE, I think). I don't know if that issues still exists, but try it out. Documentation: http://docs.jquery.com/Manipulation/clone#bool
On Aug 24, 7:10 am, Julien <tux...@gmail.com> wrote: > Hi, > > i'm trying to clone a row in a table with events attached to it. > > I initialy have the following html code to duplicate : > > <tr> > <td> > <input type="text" id="users" name="users[]" class="users" /> > </td> > <td> > <input type="text" id="expiration" name="expiration[]" > class="expirationDate" /> > <a class="addUser">+</a> > </td> > </tr> > > On the "users" input i have the autocomplete plugin and on > "expirationDate" the datepicker one. > > When i started cloning, i had the html code alright but not the > events. So i surrounded the original functions with this : $ > (".users").live("click",function(){ ending up with this : > > $(".users").live("click",function(){ > $(".users").autocomplete('/contactSearch.html', { > width: 300, > multiple: true > });}); > > $(".expirationDate").live("click",function(){ > $(".expirationDate").datepicker({ > dateFormat: 'dd/mm/yy' > }); > > }); > > Despite the fact that it doesn't sound optimized, this work with the > autocomplete plugin but no so well with datepicker. > > My question really is : there must be a better way, isn't there? > > I just need to clone the element with the javascript exactly has it is > when loaded. > > Thanks!