Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-02-2012, 08:39 PM   PM User | #1
scottlafoy
New to the CF scene

 
Join Date: Apr 2012
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
scottlafoy is an unknown quantity at this point
Select Table row within a table that has a td of foo

I have a master page with a table that contains main content and side bar content. The main content is where the different pages of the site are shown, and the side bar content has stuff like email and friends lists.

The mail list is on a model popup and when opened will ajax populate the table with rows containing image, subject, sender, time, all in different td's. When I click a row, the message pops up. From the message I can choose to reply or delete. When I delete I want to fade out the row that was deleted. I can wait the 10 seconds until the list does a refresh but I would rather have this cool visual effect.

My problem is I am having difficulty selecting the tr I want. My table has an id of MainMailTable and when I check it does not have the ct100: added in front.

Here is what I am trying:
Code:
$('#MainMailTable:tr:has(td:contains(' + subject + '))').fadeOut(1000);
I am trying to find the row that contains the subject of the message I want to delete. I guess that isnt really unique, and maybe I should add a hidden td with an id to the row (can Jquery get a hidden field?). But I would like to be able to get this first step to work.

When I try:

Code:
$('tr:has(td:contains(' + subject + '))').fadeOut(1000);
the whole page disappears, so I think I may be close.

Thank you in advance for any assistance.
scottlafoy is offline   Reply With Quote
Old 05-02-2012, 10:24 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,455
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by scottlafoy View Post
I have a master page with a table that contains main content and side bar content.
So the first thing to do to bring the HTML into the 21st Century is to get rid of the unsemantic table. The existance of the table is almost certainly the cause of your problem since there are many things that don't work properly inside tables since they don't need to when you use tables correctly.

JavaScript (including jQuery) works entirely differently within tables to how it does outside tables.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 05-03-2012, 01:54 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
??? So what is it the user clicks on to delete a *particular* row???

If it is the <td> with the subject, why not just detect the onclick of the subject and then fade out the containing row?

I mean, you are looking for contains(' + subject + ') and that implies to me that somehow the user clicked on or otherwise located that <td> already, so why do we have to look for it again??
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 05-03-2012, 02:28 PM   PM User | #4
scottlafoy
New to the CF scene

 
Join Date: Apr 2012
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
scottlafoy is an unknown quantity at this point
Quote:
Originally Posted by Old Pedant View Post
??? So what is it the user clicks on to delete a *particular* row???

If it is the <td> with the subject, why not just detect the onclick of the subject and then fade out the containing row?

I mean, you are looking for contains(' + subject + ') and that implies to me that somehow the user clicked on or otherwise located that <td> already, so why do we have to look for it again??
The user is deleting messages from a box that pops up in front of the message table so I am not deleting the table row by clicking on it. I have to find the row that brought up the message to begin with.

I have found a solution to the jquery problem, I just now have to change it to use the ID's

For anyone looking for a way to do this:
Code:
$('table table tr:has(td:contains(' + subject + '))').fadeOut(1000);
scottlafoy is offline   Reply With Quote
Reply

Bookmarks

Tags
asp, javascript, jquery

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:12 PM.


Advertisement
Log in to turn off these ads.