Bootstrap modal for multiple use -


bootstrap modal - looks pretty nice , nifty , i've seen great solutions... need help.

following task: use bootstrap 3.0 ecommerce template. i'll have lot of "popups" done before javascript lightbox same product photos. want use modal boxes, have trouble re-using them.

there need of several ones different content (product photos, shipping costs, login, , more), i've read reusing modal box , able change @ least content somehow never header or footer. example shipping information coming php page , don't want on every page loaded.

is there (simple?) way of loading contents modal box , still using different tasks? have no problem placing 1 empty modal div @ bottom of page, can't have 4 or more modals loaded "for good" every time? please give me advise.

so @ashish says change content of modal before show it, see http://jsfiddle.net/qv2cu/

html

<div class="container">     <div class="row">         <div class="col-sm-4"><button id="showvideo">video</button></div>         <div class="col-sm-4"><button id="showtext">text</button></div>         <div class="col-sm-4"><button id="showimage">image</button></div>     </div> </div>   <!-- modal --> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog"      aria-labelledby="mymodallabel" aria-hidden="true">     <div class="modal-dialog">         <div class="modal-content">             <div class="modal-header">             <button type="button" class="close" data-dismiss="modal"                     aria-hidden="true">&times;</button>             <h4 class="modal-title">modal title</h4>         </div>         <div class="modal-body">          </div>         <div class="modal-footer">             <button type="button" class="btn btn-default"                     data-dismiss="modal">close</button>             <button type="button" class="btn btn-primary">save changes</button>         </div>     </div><!-- /.modal-content --> </div><!-- /.modal-div --> 

javascript

$('#showvideo').click(function(){     $('#mymodal .modal-title').html('video');     $('#mymodal .modal-body').html('<iframe width="100%" height="315"             src="//www.youtube.com/embed/_wo9jxliqyg" frameborder="0"             allowfullscreen></iframe>');     $('#mymodal').modal('show'); });  $('#showtext').click(function(){     $('#mymodal .modal-title').html('text');     $('#mymodal .modal-body').html('praesent vitae lorem lectus. praesent ut lectus id ipsum cursus rutrum sit amet eu elit. in accumsan pulvinar nisl euismod condimentum. integer consequat, velit rhoncus vestibulum vehicula, turpis dolor euismod velit, eu volutpat eros ligula non ligula. quisque non cursus nulla, eu viverra sem. mauris dapibus id nulla @ venenatis. etiam viverra massa eu sem rhoncus commodo. praesent @ iaculis nulla. aliquam feugiat neque dui, vitae condimentum massa accumsan sollicitudin. integer pellentesque tempor augue, euismod nunc posuere a. mauris vulputate ante lectus consectetur mattis. donec tincidunt dictum vestibulum. ');     $('#mymodal').modal('show') });  $('#showimage').click(function(){     $('#mymodal .modal-title').html('image');     $('#mymodal .modal-body').html('<img src="http://dummyimage.com/300x150/000/ff">');     $('#mymodal').modal('show') });  $('#mymodal').on('hidden.bs.modal', function () {     //see: http://stackoverflow.com/questions/13799377/twitter-bootstrap-modal-stop-youtube-video     //let movie stop     $('#mymodal .modal-body').html(''); }); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -