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">×</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
Post a Comment