You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+41-25
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,21 @@ I strong recommend to use the Drupal module <a href="https://drupal.org/project/
23
23
24
24
**Models**: Created Backbone models for Nodes, Users, Comments Entities
25
25
26
+
You can add extra fields to modules to use as extra information in you application, these extra fields could be mark as *noSaveAttributes*. Check the following example.
27
+
28
+
````
29
+
var Property = Backbone.Drupal.Models.Node.extend({
30
+
initialize : function(options) {
31
+
// Setting the Id Attribute for Drupal model
32
+
this.attributes.nid = options.property_id;
33
+
this.noSaveAttributes = ['property_id'];
34
+
35
+
// Extended Backbone.Drupal.Models.Node to my own service for Drupal Nodes.
36
+
// This Rest service return absolute URL for field pictures
37
+
this.urlSource = "node_waterbed";
38
+
},
39
+
````
40
+
26
41
**Collections**: Created Backbone collection for Users, Nodes and Views
27
42
28
43
**REST**: Integration with Services Server type REST
@@ -61,31 +76,32 @@ I strong recommend to use the Drupal module <a href="https://drupal.org/project/
61
76
var Auth = new Backbone.Drupal.Auth({crossDomain: true});
62
77
// Request executed in sync mode
63
78
// If status is token further ajax will use the proper token
64
-
var status = Auth.login('admin', 'admin');
65
-
66
-
console.log(status);
67
-
68
-
/*
69
-
Check user retrieve
70
-
*/
71
-
72
-
var User = new Backbone.Drupal.Models.User({uid: 1});
73
-
User.fetch({
74
-
success: function (user) {
75
-
// Check information retrived, could be used directly in a template
76
-
console.log(user.attributes.mail);
77
-
}
78
-
});
79
-
/*
80
-
Check users retrive
81
-
*/
82
-
var Users = new Backbone.Drupal.Collections.UserIndex();
83
-
Users.fetch({
84
-
success: function (users) {
85
-
// Check information retrived, could be used directly in a template
86
-
console.log(users.models[0].attributes.uri);
87
-
}
88
-
});
79
+
var auth_status = = Auth.login('admin', 'admin');
80
+
81
+
if(auth_status) {
82
+
83
+
// Check user retrieve
84
+
85
+
var User = new Backbone.Drupal.Models.User({uid: 1});
86
+
User.fetch({
87
+
success: function (user) {
88
+
// Check information retrived, could be used directly in a template
89
+
console.log(user.attributes.mail);
90
+
}
91
+
});
92
+
93
+
// Check users retrive
94
+
95
+
var Users = new Backbone.Drupal.Collections.UserIndex();
96
+
Users.fetch({
97
+
success: function (users) {
98
+
// Check information retrived, could be used directly in a template
0 commit comments