Created
May 18, 2015 17:55
-
-
Save magnet88jp/9a88a8dbeb0954e12f92 to your computer and use it in GitHub Desktop.
backbone.modal.js sample by marionette
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="description" content="" /> | |
| <meta name="author" content="" /> | |
| <title>Backbone Modal Sample</title> | |
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /> | |
| <link href="backbone.modal.css" rel="stylesheet" /> | |
| <link href="backbone.modal.theme.css" rel="stylesheet" /> | |
| <!--[if lte IE 8]> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20140204/json2.js"></script> | |
| <![endif]--> | |
| <script src="https://code.jquery.com/jquery-1.11.3.js"></script> | |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/2.4.1/backbone.marionette.js"></script> | |
| <script src="./backbone.modal.js"></script> | |
| <script src="./backbone.marionette.modals.js"></script> | |
| <script> | |
| $(function() { | |
| var Modal = Backbone.Modal.extend({ | |
| template: '#modal-view-template', | |
| cancelEl: '.btn-cancel' | |
| }); | |
| $('#openModal').click(function(){ | |
| console.log('test'); | |
| // Render an instance of your modal | |
| var modalView = new Modal(); | |
| $('.app').html(modalView.render().el); | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <div class="app"></div> | |
| <!-- Button to trigger modal --> | |
| <a href="#modal-template" role="button" class="btn" data-toggle="modal">Launch demo modal</a> | |
| <button class="btn btn-primary" id="openModal">open</button> | |
| <script id="modal-view-template" type="text/html"> | |
| <div class="modal-header"> | |
| <h2>This is a modal!</h2> | |
| </div> | |
| <div class="modal-body"> | |
| <p>With some content in it!</p> | |
| </div> | |
| <div class="modal-footer"> | |
| <button class="btn btn-cancel">cancel</button> | |
| <button class="btn-default">Ok</button> | |
| </div> | |
| </script> | |
| <h4>参考</h4> | |
| <ul> | |
| <li>https://lostechies.com/derickbailey/2012/04/17/managing-a-modal-dialog-with-backbone-and-marionette/</li> | |
| <li>http://codezine.jp/article/detail/8270</li> | |
| <li>http://awkward.github.io/backbone.modal</li> | |
| </ul> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment