{"action":"created","issue":{"url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/14","labels_url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/14/comments","events_url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/14/events","html_url":"https://github.com/homeslicesolutions/backbone-model-file-upload/issues/14","id":53436380,"number":14,"title":"'Maximum callstack exceeded' when saving with nested attributes","user":{"login":"jbhatab","id":2458718,"avatar_url":"https://avatars.githubusercontent.com/u/2458718?v=3","gravatar_id":"","url":"https://api.github.com/users/jbhatab","html_url":"https://github.com/jbhatab","followers_url":"https://api.github.com/users/jbhatab/followers","following_url":"https://api.github.com/users/jbhatab/following{/other_user}","gists_url":"https://api.github.com/users/jbhatab/gists{/gist_id}","starred_url":"https://api.github.com/users/jbhatab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbhatab/subscriptions","organizations_url":"https://api.github.com/users/jbhatab/orgs","repos_url":"https://api.github.com/users/jbhatab/repos","events_url":"https://api.github.com/users/jbhatab/events{/privacy}","received_events_url":"https://api.github.com/users/jbhatab/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-05T19:57:30Z","updated_at":"2015-02-09T21:41:14Z","closed_at":"2015-02-09T21:41:14Z","body":"I'm having an issue similar to a previous issue posted, https://github.com/homeslicesolutions/backbone-model-file-upload/issues/2.\r\n\r\nI'm using backbone nested attributes, https://github.com/dtmtec/backbone-nested-attributes, to save my backbone models correctly with my rails backend. The problem is that when I try and save a photo on a model with any relationships, it gives me the error 'maximum callstack exceeded'. \r\n\r\nI did get the photo saving to work if I disabled a part of the flatten function, but it broke the nested part of my code. Any ideas?\r\n\r\n\r\nHere's how I changed the flatten function.\r\n\r\n```\r\n  _flatten: function( obj ) {\r\n      var output = {};\r\n      for (var i in obj) {\r\n        if (!obj.hasOwnProperty(i)) continue;\r\n        // I commented this out and made it false instead\r\n        // it at least makes the photo uploading work.\r\n        //if (typeof obj[i] == 'object') {\r\n        if (false) {\r\n          var flatObject = this._flatten(obj[i]);\r\n          for (var x in flatObject) {\r\n            if (!flatObject.hasOwnProperty(x)) continue;\r\n            output[i + '.' + x] = flatObject[x];\r\n          }\r\n        } else {\r\n          output[i] = obj[i];\r\n        }\r\n      }\r\n      return output;\r\n```"},"comment":{"url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/comments/73596161","html_url":"https://github.com/homeslicesolutions/backbone-model-file-upload/issues/14#issuecomment-73596161","issue_url":"https://api.github.com/repos/homeslicesolutions/backbone-model-file-upload/issues/14","id":73596161,"user":{"login":"homeslicesolutions","id":4754005,"avatar_url":"https://avatars.githubusercontent.com/u/4754005?v=3","gravatar_id":"","url":"https://api.github.com/users/homeslicesolutions","html_url":"https://github.com/homeslicesolutions","followers_url":"https://api.github.com/users/homeslicesolutions/followers","following_url":"https://api.github.com/users/homeslicesolutions/following{/other_user}","gists_url":"https://api.github.com/users/homeslicesolutions/gists{/gist_id}","starred_url":"https://api.github.com/users/homeslicesolutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/homeslicesolutions/subscriptions","organizations_url":"https://api.github.com/users/homeslicesolutions/orgs","repos_url":"https://api.github.com/users/homeslicesolutions/repos","events_url":"https://api.github.com/users/homeslicesolutions/events{/privacy}","received_events_url":"https://api.github.com/users/homeslicesolutions/received_events","type":"User","site_admin":false},"created_at":"2015-02-09T21:41:13Z","updated_at":"2015-02-09T21:41:13Z","body":"I'm seeing this more and more nowadays that people are nesting Backbone elements into their models and collections.  It's a really strange thing to me and I'm unsure if this is good practice as I've talked with my co-workers here.  Anyways... I'm unsure if I'm going to accept this pull request since I'm against this pattern, so maybe I would suggest for you to fork your own on this.   "}}