Happydevdays Happydevdays - 4 months ago 9
jQuery Question

can't save an object and pass to another method

I have the following code inside a table:

<tr class="16225">
<td>smtp</td>
<td>test@gmail.com</td>
<td class="grp_memberships">&nbsp;</td>
<td><a href''="">Edit</a> | <a href="">Delete</a></td>
</tr>


After the page has been rendered, I'm making an ajax call to get values for the "grp_memberships" cells.
The class value I have on the
<TR>
is actually an ID. I want to find/match rows based on this ID , and then populate the value of the grp_memberships
<td>


I can find the row using this in the console window:

$('.16225')


That returns the entire row. But I don't know how then to update the
<TD>
with the value...

Here's the jquery code i have right now:

$.each(groups, function(i, e) {
console.log(e['id'] + '-' + e['grp']);
})



e['id']


contains the value of the class that should match the

Thanks.

EDIT 1

In the console window, I tried this:

$('.16225 .grp_memberships').text('hello');


And that returned and updated the right cell for me.

So I tried to update my code to look like this:

$.each(groups, function(i, e) {
$('.' + e['id'] + ' .grp_memberships') = e['name'];
})


That outputs the following error:

Uncaught ReferenceError: Invalid left-hand side in assignment


I also tried this:

$("'." + e['id'] + " .grp_memberships'") = e['name'];


But that returns this error:


caught Error: Syntax error, unrecognized expression: '.16233
.grp_memberships'


EDIT 2:

Latest Code:

$.each(groups, function(i, e) {
alert(e['name']);
$('.' + e['id'] + ' .grp_memberships').text(e['name']);
});


This displays a message box 2 times with the various names... but the corresponding rows in the table are not updated.
:(

Answer

Try this:

$("'." + e['id'] + " .grp_memberships'").text(e['name']);