Active
Project:
Backbone
Version:
7.x-1.x-dev
Component:
JS Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2012 at 17:25 UTC
Updated:
20 Sep 2012 at 19:19 UTC
Hi! Thank you for this great module.
Please provide some exampleas of using UserModel and CommentModel. I am trying to make module which show index list of users. Code based on example app. But with no luck. I receive this error: "node is not defined .. unders...v=1.3.1 (строка 1030)".I spend so much hours with that. What I am doung wrong. Thank you. My code mdrive_app.js:
(function($) {
Drupal.behaviors.mdrive = {
// ## attach()
attach: function() {
// ### NodeView
var NodeView = Drupal.Backbone.View.extend({
templateSelector: '#mdrive-node-template',
// #### NodeView.initialize()
initialize: function(opts) {
this.model = opts.model;
this.model.bind('change', this.render, this);
Drupal.Backbone.View.prototype.initialize.apply(this);
}
});
// ### AppView
var AppView = Drupal.Backbone.View.extend({
templateSelector: '#mdrive-app-template',
// #### AppView.events
events: {
'click .loadme': 'doLoadProfile'
},
// #### AppView.initialize()
initialize: function() {
Drupal.Backbone.View.prototype.initialize.apply(this);
_.bindAll(this, 'doLoadProfile');
this.userModel = new Drupal.Backbone.UserModel();
this.userView = new NodeView({model: this.userModel});
$('#mdrive-app').append(this.render().el);
this.$('#mdrive-profile-container').append(this.userView.render().el);
},
// #### AppView.doLoadProfile()
doLoadProfile: function() {
var uid = 2;
this.userModel.set('user', uid);
this.userModel.fetch();
}
});
// ### Start the app!
var app = new AppView();
},
// ## unattach()
unattach: function() {
$('#mdrive-app').html('');
}
};
})(jQuery);
Comments
Comment #1
ethanw commentedNow that we have RestWS working, you should be able to easily adapt the new backbone_restws_examples module to work with users. I think that examples for each of the common entity types is a good idea.
Comment #2
ethanw commentedComment #3
ethanw commented