Hi All,
i am using django-tastypie to return django models as json object.
when i run the following code
but when i look a the network the model is actually fetched from the database
how do i get this data to display on the backbone view or what im i doing wrong ??
-- i am using django-tastypie to return django models as json object.
when i run the following code
var org = Backbone.Model.extend({
urlRoot: 'api/orgnanization/',
});
var orgColl=Backbone.Collection.extend({
model: org,
urlRoot: 'api/orgnanization/',
initialize:function(){
this.fetch();
console.log(this)
}
});
var apiView=Backbone.View.extend({
el:'.try',
//template:,
initialize:function(){
this.listenTo(this.collection,'reset',this.render)
},
//events:{},
render:function(){
console.log(this.collection)
//this.$el.html(this)
},
});
var cos=new orgColl()
new apiView({collection:cos})
i get the following in the chrome consoleurlRoot: 'api/orgnanization/',
});
var orgColl=Backbone.Collection.extend({
model: org,
urlRoot: 'api/orgnanization/',
initialize:function(){
this.fetch();
console.log(this)
}
});
var apiView=Backbone.View.extend({
el:'.try',
//template:,
initialize:function(){
this.listenTo(this.collection,'reset',this.render)
},
//events:{},
render:function(){
console.log(this.collection)
//this.$el.html(this)
},
});
var cos=new orgColl()
new apiView({collection:cos})
r {length: 0, models: Array[0], _byId: Object, constructor: function, model: function…}
but when i look a the network the model is actually fetched from the database
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f9c2e817-2595-4b4d-94f2-01db94e5f189%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment