Skip to content

Instantly share code, notes, and snippets.

@bmx269
Created July 6, 2017 03:49
Show Gist options
  • Save bmx269/62610e7e55268ce5eb2770e62cd0cddb to your computer and use it in GitHub Desktop.
Save bmx269/62610e7e55268ce5eb2770e62cd0cddb to your computer and use it in GitHub Desktop.
Vote forEach
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