Toggle navigation
Run LIVE DEMO
Show CODE
LIVE DEMO PAGE
Updated: 19.06.18 11:02
Basic example
<!DOCTYPE html> <html> <head> <title>A very simple smartapp2.js example</title> <!-- jQuery --> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <!-- Bootstrap --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- Smartapp --> <script src="https://smartapp.ikx.no/downloads/jquery.smartapp2.js"></script> </head> <body> <div id="AppContainer"></div> <!-- View1 added through markup --> <div id="View1" class="text-center"> <h1>The main view</h1> <p>This is the only view in this demo. It opens a dialog from the buttons below.</p> <a class="btn btn-default" data-dlgnav="Modal1">Open dialog by link</a> <a class="btn btn-primary openbycode">Open dialog by code</a> </div> <!-- Modal1 added through markup --> <div id="Modal1" class="modal fade" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Modal title</h4> </div> <div class="modal-body"> <p>One fine body…</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close by link</button> <button type="button" class="btn btn-primary closebycode">Close by code</button> </div> </div> </div> </div> <script> $(function() { // Initialize app on a DOM container element var $app = $("#AppContainer").smartapp2(); // Register a view on route #Hello (will be default view, as it is registered first) $app.createView("Hello", $("#View1"), function($me) { $me.find(".openbycode").on("click", function() { $app.openDialog("Modal1"); }); }); // Register a dialog called "Modal1" $app.createDialog("Modal1", $("#Modal1"), function($me) { $me.find(".closebycode").on("click", function() { $me.closeDialog(); }); }); // Run the application $app.run(); }); </script> </body> </html>