Last active
August 29, 2015 14:15
-
-
Save joelcox/dfac7c58d412dab36806 to your computer and use it in GitHub Desktop.
Revisions
-
joelcox revised this gist
Feb 19, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,5 +26,4 @@ resolveKeywords: function(keywords) { }); }); }, -
joelcox revised this gist
Feb 19, 2015 . 1 changed file with 13 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,17 @@ actions: { submitForm: function() { var model = this.store.createRecord('post'); this.resolveKeywords(controller.get('postKeywords')).then(function(keywords) { model.get('keywords').pushObjects(keywords); return model.save(); }).then(function() { controller.transitionToRoute('post', model); }); }); }, resolveKeywords: function(keywords) { var controller = this; -
joelcox created this gist
Feb 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ // Save action when submitting the form this.resolveKeywords(controller.get('keywords')).then(function(keywords) { model.get('keywords').pushObjects(keywords); return model.save(); }).then(function() { controller.transitionToRoute('post', model); }); // Controller function to resolve the keywords resolveKeywords: function(keywords) { var controller = this; return new Ember.RSVP.Promise(function(resolve) { var promises = keywords.map(function(item) { return controller.resolveSingleKeyword(item); }); Ember.RSVP.all(promises).then(function(keywords) { resolve(keywords); }); }); },