Partial view JavaScript running multiple times when loaded in Bootstrap modal -


i have following html modal

<div id="mdedit" class="modal fade" role="dialog" style="overflow:hidden;" data-width="800">     <div class="modal-dialog modal-lg">         <div class="modal-content">             <div>                 <img src="/content/images/ico-cross.png" style="cursor:pointer; margin:10px; float:right" class="" data-dismiss="modal" alt="">             </div>             <div class="modal-body" style="padding:25px;" id="mdbedit">             </div>         </div>     </div> </div> 

i use following script load partial view in it

function editfile(gridid, fileid, ctrl) {             var grid = $('#grid_' + gridid).data("kendogrid");             var dataitem = $("tr", grid.tbody).index($(ctrl).closest("tr"));             $.ajax({                 url: "/i9roster/editfileajax?id=" + fileid + "&dataitemno=" + dataitem + "&gridid=grid_" + gridid,                 cache: false,                 success: function (data) {                      $('#mdedit').modal('toggle');                     $('#mdbedit').html(data);                  }             });         } 

the issue facing have list of items on main page , clicking on button loads modal 1 one items runs javascript in partial view number of times modal has pop out. e.g. suppose click on first item , modal opened partial view , javascript runs once, close modal , click on other item open modal same partial view. javascript runs 2 times partial view loaded 2 times. continues happening number of times partial view loaded in modal. how fix issue?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -