[jQuery] Re: Can't get my head around this chain

2009-08-14 Thread James
I think the best place to put it is in the tr, so it's something like: tr id=row_1234 and you can retrieve it when you click on Edit (untested): var id = $(this).closest(tr).attr(id).split('_')[1]; // 1234 But for your current scenario, you can probably do something like (untested): var id =

[jQuery] Re: Can't get my head around this chain

2009-08-14 Thread Laker Netman
Thanks James. Yeah, I'd like to trim some of the bulk from this app, but I'm one of several cooks, so I have to compromise a bit ;-) Appreciate the response. Laker On Aug 14, 1:26 pm, James james.gp@gmail.com wrote: I think the best place to put it is in the tr, so it's something like:

[jQuery] Re: Can't get my head around this chain

2009-08-14 Thread Hector Virgen
That HTML should be traversable without any modifications. What I would do is traverse up to the containing tr by using $.closest() var tr = $(this).closest('tr'); Then, find the a with the name attribute: var a = tr.find('a[name]'); from there, you can pull the 5029 out of the name attribute

[jQuery] Re: Can't get my head around this chain

2009-08-14 Thread mkmanning
@OP: From your example, it appears that the number you want is the categoryid param in the anchor's href. If that's always the case, you could save all the DOM traversing and just extract it from the anchor: $('a:contains(Edit)').click(function(){ var n = /categoryid=(\d+)/.exec(this.href);