0

사용자 지정 구문 분석 기능이있는 백본 모델이 있지만이 모델에서 가져 오기를 호출하는 경우가 있는데 특정 시나리오에서 구문 분석 함수를 건너 뛰기를 원했습니다. 내가 어떻게 해. 나는 작동하지 않는 다음 옵션을 시도했다.가져 오기를 호출하는 동안 백본 모델에서 구문 분석 함수 호출을 건너 뛰는 방법

myModel.fetch({ 
      parse: false, 
      success: _.bind(function(model, response) {}, this), 
      error: _.bind(function(model, response) {}, this) 
     }); 

내 모델 코드 :

var MyModel = BaseModel.extend({ 
     initialize: function() { 
     console.log('EventCloneModel in initialize()'); 
     _.extend(Backbone.Model.prototype, Backbone.Validation.mixin); 
    }, 

    url: function() { 
     var url = gc.apiUrl; 
     var locale = "en_US" 
     url += '&locale=' + locale; 
     return url; 
    }, 

    parse: function(response) { 
      //some parsing logic goes here 
      return response; 
     }, 


    getValidations: function(){ 
     return this.validation; 
    } 

    }); 

    return MyModel; 

}); 
+1

백본 소스를 보았을 때 (아마도 그렇게했을 때),'parse : false' 옵션은 여러분이 필요로하는 것을 정확하게 수행하기 때문에 이상합니다. 어쩌면 문제가 다른 곳에 있을까요? – hashchange

+0

내 백본 버전에없는 것 같습니다 (0.9.x). – user1614862

답변

0

은 구문 분석 함수에 스킵 조건을 넣습니다. 스킵 조건을 결정하는 방법은 귀하에게 달려 있습니다.

parse: function(response) { 
     if(skipParse) 
      return response; 
     //parse the response here. If the code reaches this point, 
     //it means you want to parse it. 
     return response; 
    },