I'm having a problem fetching a model that is outside of a collection. I have seen many solutions and for some reason none seem to be working (probably doing something stupid). I have a success function in my actual fetch which never fires. It should be hitting /devices/{deviceId}
Here is my code
define([
'underscore',
'backbone',
], function(_, Backbone) {
// Creating backbone model
var DeviceModel = Backbone.Model.extend({
// set defaults
defaults: {
},
idAttribute: "deviceId",
urlRoot: '/devices'
})
return DeviceModel;
});
and I am calling it from
model = new DeviceModel({deviceId: this.deviceId })
model.fetch()
Thank you!
You could try to pass callback functions to debug what is going on with:
model.fetch()
From the documentation of BackboneJS Model-Fetch
Accepts success and error callbacks in the options hash, which are both passed (model, response, options) as arguments.
So, you can include:
model.fetch({success: function(m, resp) { console.log(resp);},
error: function(m, resp) { console.log(resp);}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.