Reputation: 13206
I'm currently trying to update the value of one row - depending on another value's row using jQuery.
For example:
If Room Allocation = Pending then the buttons Edit and Cancel appear under Actions If Room Allocation != Pending then the buttons Edit and Decline appear under Actions
How do I go about doing this?
Here is a fiddle I've included: http://jsfiddle.net/S9Gwy/
Here is my code so far:
$('.results_tbl').dataTable({
"bPaginate": true,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bAutoWidth": true
});
/*====================================
determining whether cancel or decline
button is going to appear depending on
room allocation status
=====================================*/
// find all the booking rows
var bookingRows = $('table tr.booking');
// stash a reference to the row
bookingRows.each(function () {
var row = $(this);
// if you can add a class of 'pending' to the status <td>, this becomes even cleaner and nicer...
// check the contents of the status column
if (row.find('td.status').text().toLowerCase() == 'pending') {
// add a class to the row so the CSS can do its thing...
row.addClass('pending');
}
});
Upvotes: 1
Views: 57
Reputation: 411
A first (row-level) solution might be this:
tr.booking .cancelall {
display: none;
}
tr.booking.pending .cancelall {
display: inline-block;
}
tr.booking.pending .declineall {
display: none;
}
Upvotes: 1