Skip to content
This repository has been archived by the owner on Jul 4, 2021. It is now read-only.

Fetch gives along options wich override the url in the child model #347

Open
RikSlendebroek opened this issue Oct 20, 2016 · 0 comments
Open

Comments

@RikSlendebroek
Copy link

I had a problem of models in a pageble collection not being able tofetch or calling the destroy function. We set a url function to the model by default, however models in a pageable collection have a string as url. In the end I did find the cause.

On line 1170 it sets the options url, this is set as a string if you had a function it would have been converted to string above.

      var url = options.url || this.url || "";
      if (_isFunction(url)) url = url.call(this);
      var qsi = url.indexOf('?');
      if (qsi != -1) {
        _extend(data, queryStringToParams(url.slice(qsi + 1)));
        url = url.slice(0, qsi);
      }

      options.url = url;
      options.data = data;

This doesn't cause any problems in the collection object itself, but the options are passed along when creating the childmodels resulting in the url being overridden.
Now my question is if there is a reason it has to be passed along? Since backbone fetch itself also gets the url, without placing it in the options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant