I have a table like:
When user selects Edit, it opens up a bootstrap Modal
containing all td
of the tr
the Modal is launched from. What I've done so far is:
Get Row Index on Edit Click:
$(document).on('click', '#editNominHref', function(e) {
var global_edit_row = $(this).closest('tr').index();
$('#editNomiModal').modal('show');
});
What I want is:
$('#editNomiModal').on('show.bs.modal', function () {
$("#Name_feild_of_Modal").val(name_in_td_of_nth_Tr);
// ..Similar for DOB, Relation and share%..
});
Question:
How do I pass the tr
index from Edit.click
to Modal.show
function?
I don't believe you can pass data directly to the modal. However, you can use
data
attributes to modify the DOM which can then be read from theshow.bs.modal
event. Something like this: