backbone.js change url parameter of a Model and fetch does not update data fetched

后端 未结 4 502
再見小時候
再見小時候 2021-02-04 10:28

I have the following Model:

window.MyModel = Backbone.Model.extend({
     initialize: function(props){
          this.url = props.url;
     } 

     parse: funct         


        
4条回答
  •  执笔经年
    2021-02-04 10:48

    After have understood the @tkone 's explanation...

    If you still want to have a dynamic Model.url you always can delay its construction to run time, try this:

    window.MyModel = Backbone.Model.extend({
      url: function(){
        return this.instanceUrl;
      },
      initialize: function(props){
        this.instanceUrl = props.url;
      } 
    }
    

提交回复
热议问题