In datatable declaration: fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { row_id = ($(nRow).attr("id")).split('_').pop(); $(nRow).attr("data-edit-location", '<%= controller_path %>/' + row_id + '/edit'); return nRow; } In document.ready: $('tbody').on('click', 'tr', function () { var edit_location = $(this).data("edit-location"); window.location = edit_location; });