Skip to content
This repository was archived by the owner on Jul 4, 2021. It is now read-only.
This repository was 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

@RikSlendebroek

Description

@RikSlendebroek

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions