Skip to content

Commit

Permalink
Change integration with backform set by model
Browse files Browse the repository at this point in the history
  • Loading branch information
enzolutions committed Jan 7, 2015
1 parent d8f2e5f commit e8a1c18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Backbone.Drupal is a standalone plugin to connect Marionette JS and Backbone JS

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

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.
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.


# Usage
Expand Down Expand Up @@ -56,9 +56,6 @@ Your configuration must look similar to following image.
dataType: '.json'
};
// Set Backform Compatibility (amiliaapp.github.io/backform/index.html)
//Backbone.Drupal.backform = true;
// Define auth object, set crossDomain if is necessary
var Auth = new Backbone.Drupal.Auth({crossDomain: true});
// Request executed in sync mode
Expand All @@ -69,7 +66,8 @@ Your configuration must look similar to following image.
// Check user retrieve
var User = new Backbone.Drupal.Models.User({uid: 1});
// Set Backform Compatibility (amiliaapp.github.io/backform/index.html)
var User = new Backbone.Drupal.Models.User({uid: 1, backform: true});
User.fetch({
success: function (user) {
// Check information retrived, could be used directly in a template
Expand Down
12 changes: 6 additions & 6 deletions backbone.drupal.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Backbone.Drupal.Models.Node = Backbone.Drupal.Models.Base.extend({
},

toJSON: function() {
if(Backbone.Drupal.backform) {
if(this.backform) {
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
}
else {
Expand All @@ -28,7 +28,7 @@ Backbone.Drupal.Models.Node = Backbone.Drupal.Models.Base.extend({
}
},
parse: function (data) {
if(Backbone.Drupal.backform) {
if(this.backform) {
var attributes = [];
_.each(data, function(element, index, list) {
attributes[index] = element[0].value;
Expand Down Expand Up @@ -72,7 +72,7 @@ Backbone.Drupal.Models.Comment = Backbone.Drupal.Models.Base.extend({
// Override toJSON function to nest all attributes in a { comment: ... } key
// to make this work with the Services module implementation of comment PUSH/PUT.
toJSON: function() {
if(Backbone.Drupal.backform) {
if(this.backform) {
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
}
else {
Expand All @@ -82,7 +82,7 @@ Backbone.Drupal.Models.Comment = Backbone.Drupal.Models.Base.extend({
}
},
parse: function (data) {
if(Backbone.Drupal.backform) {
if(this.backform) {
var attributes = [];
_.each(data, function(element, index, list) {
attributes[index] = element[0].value;
Expand All @@ -105,7 +105,7 @@ Backbone.Drupal.Models.File = Backbone.Drupal.Models.Base.extend({
// Override toJSON function to nest all attributes in a { file: ... } key
// to make this work with the Services module implementation of file PUSH/PUT.turn data;
toJSON: function() {
if(Backbone.Drupal.backform) {
if(this.backform) {
return Backbone.Drupal.Models.Base.prototype.toJSON.call(this);
}
else {
Expand All @@ -115,7 +115,7 @@ Backbone.Drupal.Models.File = Backbone.Drupal.Models.Base.extend({
}
},
parse: function (data) {
if(Backbone.Drupal.backform) {
if(this.backform) {
var attributes = [];
_.each(data, function(element, index, list) {
attributes[index] = element[0].value;
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"backbone.drupal.js",
"backbone.drupal.services.js"
],
"version": "0.2.1-alpha",
"version": "0.2.1-beta",
"homepage": "http://enzolutions.com/projects/backbone_drupal/",
"author": {
"name": "enzo - Eduardo Garcia",
Expand Down

0 comments on commit e8a1c18

Please sign in to comment.