---
title: "backbone 学习笔记"
author: "plkong"
date: "2014-04-13T08:59:58Z"
tags: []
categories: ["编程语言"]
slug: "backbone"
draft: false
lastmod: "2014-06-09T14:52:27Z"
id: 2044264
url: "https://plkong.iteye.com/blog/2044264"
---

3种情况可以触发validate

1. save() model 的时候  
   person.save();  
   console.log(person.validationError); //显示：年龄错误
2. set property的时候强制检查，用{validate: true}  
    person.set({  
      age: 100  
    },  {validate: true});  
    console.log(person.validationError); //显示：年龄错误
3. 调用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://fontawesome.io/](http://fontawesome.io/)

 

[http://www.prepbootstrap.com/bootstrap-theme](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