javascript - Using a data attribute to pass information to a modal: is there a way to pass more than one piece of information? -


i'm using following code pass variable modal:

<button type="button" class="btn btn-primary" data-toggle="modal"                              data-target="#examplemodal" data-whatever="<?php echo urlencode($parkrow['name']) ?>">open modal <?php echo                              $parkrow['name']; ?></button> 

and javascript:

$('#examplemodal').on('show.bs.modal', function (event) {      var div = document.getelementbyid("dom-target");     var mydata = div.textcontent;   var button = $(event.relatedtarget)    var recipient = button.data('whatever')    var modal = $(this)   modal.find('.modal-header').text('new message ' + recipient)   modal.find('.modal-body input').val(mydata) 

is there way send more 1 piece of information? i've tried doing through array , bunch of other ways, can't seem make work.

something ?

<div data-foobar='{"foo":"bar"}'></div> 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -