Reputation:
I have the row id available of a table, then how is it to get the contents of the row having three columns into my JS variables. Iam trying to bring the contents of a row into my popup, so i put a check box and when it is checked i can get the row id. The next step was to populate the data into my popup. I thought of calling an Ajax request , but there should be a JQuery way to get the data?
EDIT :
This is how i get the row number from the check box
if ($('.cbox1:checked').length) {
var id = '';
$('.cbox1:checked').each(function () {
id = $(this).val();
});
The HTML of the row where i populate from Table is :
<tr contenteditable="false" class="content<?php echo $record->ID;?>" id="<?php echo $record->ID;?>">
Upvotes: 1
Views: 1550
Reputation: 2606
If it's truly an ID, then it should be unique to the entire DOM. So, you can just query it.
var columns = [];
$('#yourRowId').find('td').each(function(){
columns.push($(this).text());
});
console.log(columns);
I'm not sure what kind of popup you are talking about. If it is an entirely separate page opening in a new window, you will not be able to access the DOM of the original page. So, an alternative would be when they perform the action to cause the popup to show, tack on the data as query parameters and then read the parameters off the url in the popup. Otherwise, you might need to incorporate some backend logic into things.
Upvotes: 1