Skip to content

Commit e8a1c18

Browse files
committed
Change integration with backform set by model
1 parent d8f2e5f commit e8a1c18

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Backbone.Drupal is a standalone plugin to connect Marionette JS and Backbone JS
1919

2020
Originally Inspired in JS files from Drupal 7 Module <a href="https://drupal.org/project/backbone" target="_blank">https://drupal.org/project/backbone</a>
2121

22-
Backbone.Drupal has compatibility with [Backform](http://amiliaapp.github.io/backform/index.html) Drupal 8 return an object for each property if you enable this compatibility attibuttes will be flatten to an array with value property. But this feature could be used for other implementations.
22+
Backbone.Drupal has compatibility with [Backform](http://amiliaapp.github.io/backform/index.html) Drupal 8 return an object for each property if you enable this compatibility attibuttes will be flatten to an array property -> value. But this feature could be used for other implementations.
2323

2424

2525
# Usage
@@ -56,9 +56,6 @@ Your configuration must look similar to following image.
5656
dataType: '.json'
5757
};
5858
59-
// Set Backform Compatibility (amiliaapp.github.io/backform/index.html)
60-
//Backbone.Drupal.backform = true;
61-
6259
// Define auth object, set crossDomain if is necessary
6360
var Auth = new Backbone.Drupal.Auth({crossDomain: true});
6461
// Request executed in sync mode
@@ -69,7 +66,8 @@ Your configuration must look similar to following image.
6966
7067
// Check user retrieve
7168
72-
var User = new Backbone.Drupal.Models.User({uid: 1});
69+
// Set Backform Compatibility (amiliaapp.github.io/backform/index.html)
70+
var User = new Backbone.Drupal.Models.User({uid: 1, backform: true});
7371
User.fetch({
7472
success: function (user) {
7573
// Check information retrived, could be used directly in a template

backbone.drupal.services.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Backbone.Drupal.Models.Node = Backbone.Drupal.Models.Base.extend({
1818
},
1919

2020
toJSON: function() {
21-
if(Backbone.Drupal.backform) {
21+
if(this.backform) {
2222
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
2323
}
2424
else {
@@ -28,7 +28,7 @@ Backbone.Drupal.Models.Node = Backbone.Drupal.Models.Base.extend({
2828
}
2929
},
3030
parse: function (data) {
31-
if(Backbone.Drupal.backform) {
31+
if(this.backform) {
3232
var attributes = [];
3333
_.each(data, function(element, index, list) {
3434
attributes[index] = element[0].value;
@@ -72,7 +72,7 @@ Backbone.Drupal.Models.Comment = Backbone.Drupal.Models.Base.extend({
7272
// Override toJSON function to nest all attributes in a { comment: ... } key
7373
// to make this work with the Services module implementation of comment PUSH/PUT.
7474
toJSON: function() {
75-
if(Backbone.Drupal.backform) {
75+
if(this.backform) {
7676
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
7777
}
7878
else {
@@ -82,7 +82,7 @@ Backbone.Drupal.Models.Comment = Backbone.Drupal.Models.Base.extend({
8282
}
8383
},
8484
parse: function (data) {
85-
if(Backbone.Drupal.backform) {
85+
if(this.backform) {
8686
var attributes = [];
8787
_.each(data, function(element, index, list) {
8888
attributes[index] = element[0].value;
@@ -105,7 +105,7 @@ Backbone.Drupal.Models.File = Backbone.Drupal.Models.Base.extend({
105105
// Override toJSON function to nest all attributes in a { file: ... } key
106106
// to make this work with the Services module implementation of file PUSH/PUT.turn data;
107107
toJSON: function() {
108-
if(Backbone.Drupal.backform) {
108+
if(this.backform) {
109109
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
110110
}
111111
else {
@@ -115,7 +115,7 @@ Backbone.Drupal.Models.File = Backbone.Drupal.Models.Base.extend({
115115
}
116116
},
117117
parse: function (data) {
118-
if(Backbone.Drupal.backform) {
118+
if(this.backform) {
119119
var attributes = [];
120120
_.each(data, function(element, index, list) {
121121
attributes[index] = element[0].value;

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"backbone.drupal.js",
55
"backbone.drupal.services.js"
66
],
7-
"version": "0.2.1-alpha",
7+
"version": "0.2.1-beta",
88
"homepage": "http://enzolutions.com/projects/backbone_drupal/",
99
"author": {
1010
"name": "enzo - Eduardo Garcia",

0 commit comments

Comments
 (0)