I have this view with a modal window. When I click to open the modal window, I\'d like to pass the parameter item.InstrumentId
into the modal window so that I can c
You currently generating a modal for each item in your collection but giving it an id="myModal"
which is invalid html and means data-target="#myModal"
will only ever open the first one. Move the modal outside the loop so your create only one (and also remove the element which also has the same
id
attribute)
Then change the button html to
and change the html in the modal to
Instrument: Details
Then change the script to
$(document).on("click", ".open-dialog", function() {
$('#details').attr('href', $(this).data('url')); // update the links url
})
Side note: You will probably want to do something similar with Checked: @item.Checked
in the modal