Created
June 12, 2014 12:20
-
-
Save cherifGsoul/70dab9d17d6868c21584 to your computer and use it in GitHub Desktop.
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://code.jquery.com/jquery.min.js"></script> | |
| <script src="//canjs.com/release/2.1.1/can.jquery.dev.js"></script> | |
| <script src="//canjs.com/release/2.1.1/can.map.define.js"></script> | |
| <script src="//canjs.com/release/2.1.1/can.stache.js"></script> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
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
| can.Map.extend('AppState',{ | |
| define:{ | |
| page:{ | |
| set:function(val){ | |
| return val ? val : 'home'; | |
| }, | |
| view:{ | |
| set:function(val){ | |
| return val ? val : 'index'; | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| can.Component.extend({ | |
| tag:'x-app', | |
| template:'Here', | |
| init:function(){ | |
| can.route.map(this.scope); | |
| can.route(':app',{ | |
| app:'home', | |
| view:'index' | |
| }); | |
| can.route.ready(); | |
| }, | |
| scope:function(){ | |
| return new AppState(); | |
| }, | |
| events:{ | |
| init:function(el){ | |
| el.addClass('container'); | |
| el.append(can.mustache('<x-navigator class="pop"/>')); | |
| }, | |
| inserted:function(el,ev){ | |
| var d=JSON.stringify(can.route.attr()); | |
| el.find('x-navigator').append(d); | |
| } | |
| } | |
| }); | |
| $('body').append(can.stache('<x-app/>')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment