Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模型 #31

Open
xspider opened this issue Jun 3, 2013 · 0 comments
Open

模型 #31

xspider opened this issue Jun 3, 2013 · 0 comments
Labels

Comments

@xspider
Copy link
Collaborator

xspider commented Jun 3, 2013

<<返回目录

Model 是SPA类应用程序的核心,包括数据的获取、转换、验证、访问控制等。Model 也提供了一组基本的管理变化的功能。

下面的示例演示了如何定义一个模型,包括自定义方法、设置属性、以及触发该属性变化的事件。

Chassis.Model.define( 'sidebar', {
  promptColor: function() {
      var cssColor = prompt( '请输入一个CSS颜色值:' );
      this.set({ color: cssColor });
  }
} );

var sidebar = Chassis.Model.create( 'sidebar' );

sidebar.bind('change:color', function(model, color) {
  $('#sidebar').css({background: color});
});

sidebar.set({color: 'white'});

sidebar.promptColor();

<<返回目录

@xspider xspider mentioned this issue Jun 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant