I have a jQuery function which looks like this:
function unlock_reservation_columns(resid) {
$('.unlock-columns').click( function(event) {
event.preventDefault();
$(this).closest('tr').find('.columns-locked').removeClass('columns-locked');
$(this).html('<i class="fa fa-lock"></i> Lock Columns');
$(this).attr('class', 'lock-columns');
new PNotify({
title: 'We have unlocked this reservation..',
text: 'Reservation Unlocked',
type: 'success'
});
var url = $(this).attr("href");
var url_id = url.replace(/[^0-9]/g, '')
$.get(url, function (data) {
var confirm_changes = confirm('Do you wish to edit unlocked information?');
if (confirm_changes) {
window.location.href = '/reservations/database/edit/' + url_id;
}
else {
location.reload()
return false;
}
});
});
});
<a class="unlock-columns" href="<?php echo $row->unlock_url; ?>"><i class="fa fa-unlock"></i> Unlock Columns</a>
The button "unlock-columns" is located inside a Datatable custom column. Now when the page is only initialized this button works fine. After i sort something in the table. the (data-order-by) and click the button it doesn't work.. like after sorting it stops working. any ideas why?