jquery - Passing data to bootstrap modal -


after searching alot find many solution pass data model nothing work , code can point out making mistake? when clicked model nothing shows up. , can through php ? whitout using javascript

<td>     <a data-id="<?echo $comments;?>" class="open-addbookdialog" href="#mymodal"><?echo substr($comments,0,10)?></a> </td>  <div class="modal fade" id="#mymodal" role="dialog">     <div class="modal-dialog">         <div class="modal-content">             <div class="modal-header">                 <button type="button" class="close" data-dismiss="modal">&times;</button>                 <h4 class="modal-title">modal header</h4>             </div>             <div class="modal-body">                 <p>                     text                 </p>                 <input type="text" name="bookid" id="bookid" value="" />             </div>             <div class="modal-footer">                 <button type="button" class="btn btn-default" data-dismiss="modal">close</button>             </div>         </div>     </div> </div> 

jquery

 $(document).on("click", ".open-addbookdialog", function (e) {      e.preventdefault();      var _self = $(this);      var mybookid = _self.data('id');     $("#bookid").val(mybookid);      $(_self.attr('href')).modal('show'); }); 

change this:

<div class="modal fade" id="#mymodal" role="dialog"> 

to this:

<div class="modal fade" id="mymodal" role="dialog"> 

...without '#'


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -