3种情况可以触发validate
-
save() model 的时候
person.save();
console.log(person.validationError); //显示:年龄错误 -
set property的时候强制检查,用{validate: true}
person.set({
age: 100
}, {validate: true});
console.log(person.validationError); //显示:年龄错误 -
调用isValid()手动检查
person.isValid();
console.log(person.validationError); //显示:年龄错误
另外如果有验证错误model会trigger特殊invalid事件,这样可以在有错误的时候才显示错误
person.on("invalid",function(model,error){
console.log(error.validationError); //显示:年龄错误
});
fetch数据时,IE报304错误,解决办法:http://blog.sina.com.cn/s/blog_4b7809800100y1c3.html
this.commentList.fetch({
url: "ax/comment/"+this.model.get("id"),
data:{token: new Date().getTime()},
success : function(data){
$(that.el).find(".comments").html(new CommentListView({model: data}).render().el);
}
});
http://www.ibm.com/developerworks/cn/web/0907_osgiweb_liuqing/
http://www.cnblogs.com/skyme/archive/2012/07/10/2583952.html
http://javascript.ruanyifeng.com/
http://www.prepbootstrap.com/bootstrap-theme
http://coenraets.org/blog/2012/01/using-backbone-js-with-a-restful-java-back-end/
https://weblogs.java.net/blog/caroljmcdonald/archive/2013/09/16/example-backbonejs-jax-rs-jpa-application
https://code.google.com/p/crypto-js/#CryptoJS_3.1
http://blog.csdn.net/hf81970/article/details/13508231
http://www.teaching-materials.org/backbone/#/
https://github.com/jashkenas/backbone/wiki/Tutorials%2C-blog-posts-and-example-sites
https://github.com/addyosmani/backbone.paginator
https://github.com/alexanderscott/backbone-login
http://blog.42floors.com/user-authentication-with-rails-and-backbone-js/
restful ajax web app
http://thomasdavis.github.io/tutorial/making-a-restful-ajax-app.html