i'm creating modal form part of asp.net mvc project.
the page displays list of people, these people items associated button. when button pressed next person, want display person's name in model.
my issue getting record button associated with, can display data particular record. have tried using integer, increments on each record. here pseudo-code:
list = ordered list of records people table in database int = 0; foreach item in list ..display info.. <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#mymodal_@i">add action</button> <div class="modal fade" id="mymodal_@i" role="dialog" data-backdrop="false"> .. <div class="modal-body"> ... ??? i++; any appreciated.
if need name add data attribute button.
<button data-name="@name" data-toggle=.....> <!-- not sure razor syntax @name--> then element in modal insert name
<div class="modal-body"> <div class="modal-name"></div> </div> and add click handler
$('button['data-toggle="modal"]).click(function(){ $( $(this).data('target') +' .modal-name').text( $(this).data('name')); });
Comments
Post a Comment