javascript - Overriding model's urlRoot to a function fails -


when try override urlroot attribute of model , fetch on model, urlroot returns whole function string. here overridden urlroot looks like:

urlroot: function() {   return "test"; }, 

it returns following: http://localhost:8000/items/function%20()%20%7b%20%20%20%20%20%20return%20%22test%22;%20%20%20%20%7d

also, items portion of url come from?

urlroot expected static string

  • defined either during construction or

  • during runtime

you can override url function if logic lies in construction of url.

example

backbone.model.extend({  .. urlroot:"test", url:function(){  return this.urlroot + "/" + this.cid;  }, ..  }): 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -