jquery - How to show a URL in Bootstrap Modal dialog: On button click -


i have load page (internal url) in modal window. had been using window.showmodaldialog(url, null, features) not work on safari,chrome. decided use bootstrap's modal dialog instead. i'm unable make work. ideas doing wrong?

    //imports     <script src="http://code.jquery.com/jquery.js"></script>     <script src="js/bootstrap.min.js"></script>     <link href="css/bootstrap.min.css" rel="stylesheet">       //activate content modal       $(document).ready(function(){             $('#test_modal').modal({                  });     }      .......     .......      $("#btnsubmit").click(function(){      var url = constructrequesturl();       $('#test_modal').modal(data-remote=url,data-show="true");     });       -----     -----     <div class="modal fade" id="test_modal"> </div> 

if you're going continue down bootstrap path, take here: jsfiddle - remote uri in bootstrap 2.3.2 modal

note url need on same domain (though mentioned "internal") or domain need allowed remote site's access-control-allow-origin settings. keep in mind fiddle demo can't load content example.com.

<button type="button" class="btn" data-toggle="modal" data-target="#mymodal" data-remote="http://example.com">launch modal</button>  <div id="mymodal" class="modal hide fade">     <div class="modal-header">         <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>         <h3 id="mymodallabel">modal header</h3>     </div>     <div class="modal-body">        <!-- remote content inserted here via jquery load() -->     </div>     <div class="modal-footer">         <button class="btn" data-dismiss="modal" aria-hidden="true">close</button>     </div> </div> 

you don't need write custom javascript - bootstrap know based on data-attributes data-remote="http://example.com/whatever" , data-target="#mymodal" etc.

see relevant section of bootstrap modal docs more info...

edit: turns out changing remote url dynamically isn't easy be. this answer further.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -