views:

130

answers:

1

I'm trying to get to the row that is "current" in GMail Inbox view, the one marked by a little triangle on the left. The one you can change using j,k hotkeys. I came up with this but it still returns every row.

jQuery("#canvas_frame").contents().find('tr#.zA>td:first-child>img[style]')

I need two selectors - one for the current row and another for every other row, not including the current.

Thanks.

+1  A: 

Ok I messed around with it, you can select the current row with

var selectedRow = jQuery("#canvas_frame").contents()
 .find('tr').removeClass('sel').end()
 .find('.oZ-jd[style*=visibility]').closest('tr').addClass('sel');

var nonSelectedRows = selectedRow.closest('table').find('tr').not('.sel');
fudgey
Sorry, I had to update the code, I missed the `.end()`
fudgey
That works, thanks. What's the etiquette, should I accept your answer and post another question as follows?I can't make it work inside keyup:$().keyup(listenJK);function listenJK(event){ var key = {j: 74, k: 75 }; switch (event.keyCode){ case key.j: case key.k: var current_row = jQuery("#canvas_frame").contents().find('tr').removeClass('sel').end().find('.oZ-jd[style*=visibility]').closest('tr').addClass('sel'); alert(jQuery("#canvas_frame").contents().length); }}I'm getting "0" in the alert.
nameanyone
It might be best to ask a separate question, because if I am unable to answer the next question, it's rare that older questions are even looked at... but, in your code, it looks like `$()` should be `$('#canvas_frame').contents()` or maybe try binding a live event to the keyup inside the iframe. I'll try it later when I have more time.
fudgey
Thanks, fudgey. I'm very new to this, can't make any sense out of "try binding a live event to the keyup inside the iframe".
nameanyone