tupai.js is a minimal and flexible JavaScript MVC framework.
providing a robust set of features for building single and multi-pages.
Install with npm. If you were not installed node, install node (Joyent, Inc,).
$ npm install tupaijs
Generate project Use tupaijs command.
$ tupaijs new helloworld
Start server.
$ cd helloworld; tupaijs server
Open in browser
$ http://localhost:9800
That's All♡
Generate controller.
$ tupaijs g controller sub
Edit templates/helloworld/Templates.html add an button to "div#helloworld.RootViewController.content".
$ <button data-ch-id="btnGotoSub">goto sub</button>
Edit templates/helloworld/Templates.html add an button to "div#helloworld.SubViewController.content".
$ <button data-ch-id="btnBack">back</button>
First, in order to change the contents of the text that is displayed on the screen, viewInit function is modified as follows.
viewInit: function() {
var view = new cp.View({
template:cp.Templates.get('helloworld.RootViewController.content'),
templateParameters: {
lbl: 'RootViewController'
}
});
this.setContentView(view);
},
ViewDidLoad function is as follows, adding the processing of a button.
viewDidLoad: function (view) {
var This = this;
view.findViewById('btnGotoSub').bind('click', function() {
This._window.transitWithHistory('/sub');
});
},
First, in order to change the contents of the text that is displayed on the screen, viewInit function is modified as follows.
viewInit: function() {
var view = new cp.View({
template: cp.Templates.get('helloworld.SubViewController.content'),
templateParameters: {
lbl: 'SubViewController'
}
});
this.setContentView(view);
},
ViewDidLoad function is as follows, adding the processing of the back button.
var This = this;
view.findViewById('btnBack').bind('click', function() {
This._window.back();
});