ItyJavaScript MVC 框架
Ity 是一个小型的无依赖的 JavaScript MVC 框架。
示例代码:
var myApp = new Ity.Application(); var myModel = new Ity.Model(); var myView = new Ity.View({ el: '.someElement', app: myApp, model: myModel, events: { ".btn" : { "click": "onBtnClick", "hover": "onBtnHover" }, ".fancyBtn" : { "click": "onFancyBtnClick", "focus": "onFancyBtnFocus" } }, initialize: function(options) { this.model.on("change", this.render, this); }, render: function() { this.select(".myContainer").html(this.model.get("someData")); }, onBtnClick: function(evt) { var output = this.select("#difWithId").find(".output"); output.html("<div><p>Click!</p></div>") } //... more click, hover, focus events from events hash });
评论