[jQuery] Re: Event is not triggered when the tr removed from one table to another table

2009-05-18 Thread James

Any future elements added to the DOM will not automatically inherit
events that are set on the page.
Try using the live() function to set your dblclick:

$(tr).live(dblclick, function(event) {...});

More info on it here: http://docs.jquery.com/Events/live#typefn

On May 18, 8:04 am, naresh pokuri...@gmail.com wrote:
 Hi I have a query(JQuery) here. can you plz help me in fixing the
 issue with this code.

 That is when I click on tr of first table that should get removed
 from first table and added to second table. It is happening fine and
 good. But when I double click on the tr that is added to second
 table no event is triggered. Why?

 $(tr).dblclick(function(event){
                 var row = $(this).html();
                 $(this).remove();
                 $(#bottomTable).append(tr+row+/tr);

 });

 do I need to call any method?


[jQuery] Re: Event is not triggered when the tr removed from one table to another table

2009-05-18 Thread Karl Swedberg



On May 18, 2009, at 2:04 PM, naresh wrote:



Hi I have a query(JQuery) here. can you plz help me in fixing the
issue with this code.

That is when I click on tr of first table that should get removed
from first table and added to second table. It is happening fine and
good. But when I double click on the tr that is added to second
table no event is triggered. Why?

$(tr).dblclick(function(event){
var row = $(this).html();
$(this).remove();
$(#bottomTable).append(tr+row+/tr);
});

do I need to call any method?


It looks like you're doing more than you need to. When you  
use .remove(), jQuery removes all event and data bindings from the  
element(s) as well. But you don't even need to remove the row.

Make sure you have a tbody in your table, then do this instead:

$(tr).dblclick(function(event){
$(this).appendTo(#bottomTable  tbody);
});



--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: Event is not triggered when the tr removed from one table to another table

2009-05-18 Thread Josh Nathanson

Events are not automatically bound to new elements added to the dom.
However if you are using jquery 1.3+ you can do this to achieve dynamic
binding:

$(tr).live(dblclick,function(event) {
// etc.

-- Josh

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of naresh
Sent: Monday, May 18, 2009 11:05 AM
To: jQuery (English)
Subject: [jQuery] Event is not triggered when the tr removed from one
table to another table


Hi I have a query(JQuery) here. can you plz help me in fixing the
issue with this code.

That is when I click on tr of first table that should get removed
from first table and added to second table. It is happening fine and
good. But when I double click on the tr that is added to second
table no event is triggered. Why?

$(tr).dblclick(function(event){
var row = $(this).html();
$(this).remove();
$(#bottomTable).append(tr+row+/tr);
});

do I need to call any method?



[jQuery] Re: Event is not triggered when the tr removed from one table to another table

2009-05-18 Thread Karl Swedberg


On May 18, 2009, at 2:30 PM, Josh Nathanson wrote:



Events are not automatically bound to new elements added to the dom.
However if you are using jquery 1.3+ you can do this to achieve  
dynamic

binding:

$(tr).live(dblclick,function(event) {
// etc.


True, but the OP was referring to rows that were already there in the  
first place. All he has to do is append them to the #bottomTable  
tbody without first using .remove()


$(tr).dblclick(function(event){
$(this).appendTo(#bottomTable  tbody);
});

Works great. Less filling.

--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com