Hi Freud,

You might want to try adding an "event" argument to the click handler:

$(document).ready(function() {
  $("tr.clickme").click( function(event)
  {
     if ( !$(event.target).is('a') ) {
        var ids = $(this).attr('id').split('_');
        var id = (ids[(ids.length-1)]);
        $("#showme_"+id+" >div").each(function(){ $(this).toggle(); });
        $("#showme_"+id).toggle();
      }
  } );
});

This first makes sure that "event.target" is not a link before it does the toggle.

Hope that helps.


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Dec 6, 2007, at 10:09 AM, Freud wrote:



Hi,

I'm facing a "stupid" stuff.
I have a table. When I click on a TR, it displays another TR containing
datas :

<table>
<tr id="clickme_1" class="clickme">
<td>
Data - Data -
http://www.site.com Link
- Data
</td>
</tr>
<tr id="showme_1" class="showme">
<td>
<div id="showmore_1" class="showmore">
Extra Data -
<div>Another Div</div>
-  http://www.site.com Extra Data
- Extra Data
</div>
</td>
</tr>
</table>

It works perfectly with a toggle :

$(document).ready(function() {
$("tr.clickme").click( function()
{
var ids = $(this).attr('id').split('_');
var id = (ids[(ids.length-1)]);
$("#showme_"+id+" >div").each(function(){ $(this).toggle(); });
$("#showme_"+id).toggle();
} );
});

But, when I click on a link (ID:link_1) inside the TR (ID:clickme_1), it
triggers the toggle effect.
I whish I could :
- click "anywhere" on the TR and trigger the toggle
- not trigger the toggle if i clicked on a link (juste open the new window)

The problem is that the first triggered effect is the TR click and I can't
find the way to prevent the effect when the link is clicked.

Can anyone help me ?
Freud



--
View this message in context: 
http://www.nabble.com/Toggle-on-TR.onclick-but-not-on-content-link-tf4956507s27240.html#a14193890
Sent from the jQuery General Discussion mailing list archive at Nabble.com.


Reply via email to