backbone.js - Customizing backbone models to work with urls like /documents/6/editor -


It is possible to override the backbone model's URL method to enter an ID between the URL string.

I do not want to get this from

  documents / 6  

, but it < / P>

  documents / 6 / editor  

and similiary update

  documents / 6 / editor  

Currently insisting on adding vertebra bone ID at the end of the url string.

I tried

  urlRoot: function () {return "/ documents" + this.id + "/ editor"; }  

Although this works to get a model from the server, it fails on the update. It seems that the URL

  / documents / 6 / editor / 6  

and not

  / document overriding replaces the prefix of your URL and later on  

Try

  var M = backbone.Model.extend ({urlRoot: '/ documents', url: function () {var base = backbone.Model.prototype.url. Call (this ); If (this innovation) returns, return on the basis + '/ editor';}});  

and a demo


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -