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("
Click!
") } //... more click, hover, focus events from events hash });