Hi

I found this reply really useful..
Event handlers are not preserved when cloning elements.
So:
* you can reassign the event handlers to the cloned elements or
* you can use the copyEvents plugin: <http://www.learningjquery.com/2007/01/copy-events-from-one-element-to-another>

Best.
I have a table that has a hidden 1st row, this is the chunk of code that gets cloned :)
This row has several form fields and a mouseover of the TR which toggles a delete image for that row.

I tried several ways todo it and this was the ONLY WAY TODO IT.

Though looking at the 1st option i did'nt reassign the event handlers so i opted for the copyEvents plugin.

Triggsley
On 22/02/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
  
Hi,

If I have

$(this).parents("div.sidebarToDo").find("td.sidebarText").empty().append('<input type="text" value="" size="10" class="editableItem">');

What is the best way to get a reference to the newly created text field?  Note that it does not have an ID and I would prefer a more generic way of finding it other than "input.editableItem" because on PC IE 6, if I insert multiple text fields, like the above, this call  ...

$(this).parents("div.sidebarToDo").find("input.editableTDItem");

only returns a correct reference for the first time a textfield is added.  I cant get the most recent addition with the above call if there had been text fields added in the past.

Thanks, please let me know what info I can provide to make this question more clear, - Dave
    

You could try this:

var editableitem = $('<input type="text" value="" size="10"
class="editableItem">');
$(this).parents("div.sidebarToDo").find("td.sidebarText").empty().append(editableitem);
editableitem.change(checkText);

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


  

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to