views:

3331

answers:

4

Hello,

I'm having an issue trying to NOT select a tablerow with the function:

$("tr").click(function(e) {
 var row = jQuery(this)
//rest of code left off 
});

Basically it finds all tablerows and adds click functionality that will open a edit modal that has a row with textboxes that are populated with info from the tablecells. The problem is that the tablerow in the modal is also getting the functionality so when a user goes to edit a value in a text box the all the values disappears...

So what I have been trying and failing is to filter the tr by id several way by using:

$("tr").not('trEdit').click(function(e) {
            var row = jQuery(this)

and

$("tr not:'trEdit').click(function(e) {
            var row = jQuery(this)

I've also played around with trying the second table and then not selecting it's table rows, but the tables aren't besides each other & the example I had was...no I haven't tried table[1] tr yet(now that I think about it)...

Please help...I'm going nuts trying to figure this out..

Thanks!!!!!

A: 

I've never used the ':not' syntax but the following should give you what you need for this example:

$("tr[id!='trEdit']").click(function(e) {
    var row = jQuery(this)
brendan
+3  A: 

The syntax is either $("tr:not(.trEdit)") or $("tr :not(.trEdit)") - depending on if the trEdit class applies to the tr or a sub-element.

However, I think your problem may have to do with event bubbling - you'll have to search for details on that, or wait for someone else to extend the answer, as I have to go now.

Peter Boughton
+1  A: 

Your problem is that the "trEdit" in your not filter should be either ".trEdit" or "#trEdit", depending on what you meant to do (note the dot and the hash).

bigmattyh
A: 

Could you implement it this way? It would make your intentions much clearer.

$("#theClickableTable tr").click(function() {
    ...
})
Alex Barrett
That got it....makes so much sense too! I'm obviously a jquery newb, but I love it!Thanks again!!!
wali
I've just edited my comment slightly, as part of it was unnecessary. It still does exactly the same thing though.
Alex Barrett