javascript - Backbone JS Model -


in youtube tutorial saw different way of declaring model:

model = backbone.model({ data:[     {text:"google", href:"https://google.com"},     {text:"facebook", href:"https://facebook.com"},     {text:"youtube", href:"https://youtube.com"}   ]  }); 

my console log throwing error:

uncaught typeerror: object # has no method 'set'

is right way it?

try this:

var model = backbone.model.extend({     data:[         {text:"google", href:"https://google.com"},         {text:"facebook", href:"https://facebook.com"},         {text:"youtube", href:"https://youtube.com"}    ] }); 

so, related here, creating bakbone.model() means creation of custom model, , appear wanting, create model need use backbone.model.extend().


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -