backbone.js - A "url" property or function must be specified -
i'm trying download collection of documents mongodb, using nodejs, browser, using backbone. can use simple ajax request take advantage of backbone, backbone should request.
there empty collection:
//create model , collection task_lists var mtasklist = backbone.model.extend({ defaults: { title: 'untitled task list' }, urlroot: '/task_list' }); var ctasklists = new backbone.collection({ model: mtasklist, url: '/task_list' });
when try fetch data server:
ctasklists.fetch({reset: true, data: {workspace: swsurl}}); //ask data server
it throws error: uncaught error: "url" property or function must specified
i tried different combinations of url same error thrown.
the first parameter expected in collection constructor list of models, options hash comes second:
constructor / initialize new collection([models], [options])
when creating collection, may choose pass in initial array of models.
try
var ctasklists = new backbone.collection([], { model: mtasklist, url: '/task_list' });
and fiddle play http://jsfiddle.net/nikoshr/l4xsj/
Comments
Post a Comment