Created
July 6, 2017 03:49
-
-
Save bmx269/62610e7e55268ce5eb2770e62cd0cddb to your computer and use it in GitHub Desktop.
Vote forEach
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 characters
saveVote() { | |
var votePromises = []; | |
this.get('voteItems').forEach(item => { | |
item.set('isSelected', false); | |
let itemId = item.get('id'); | |
let itemTitle = item.get('title'); | |
let itemImage = item.get('fieldImage.url'); | |
let currentCampaign = this.get('campaign.id'); | |
let newVote= this.store.createRecord('node--vote', { | |
title: itemTitle, | |
fieldItemid: itemId, | |
fieldCampaignid: currentCampaign, | |
fieldImageUrl: itemImage | |
}); | |
votePromises.push(newVote.save()); | |
}); | |
Ember.RSVP.all(votePromises).then(() => { | |
const campaignId = this.get('campaign.id'); | |
this.transitionToRoute('kiosk.result', campaignId); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment