-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtryout.js
32 lines (28 loc) · 1.03 KB
/
tryout.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Team = new Mongo.Collection('teams');
if (Meteor.isClient) {
Template.teams.onRendered(function () {
var drake;// = dragula($(document.querySelectorAll('#dragulaContainer')).toArray());
Meteor.setTimeout(function () {
drake = dragula($('.dragula-container').toArray());
drake.on('drop', function (el, target, source) {
var targetTeamId = target.dataset.team;
if (targetTeamId) { //don't change db collection if this is just moving to temporary container
var playerId = el.dataset.id;
Meteor.call('swapTeams', playerId, targetTeamId);
}
});
}, 4000);
});
Template.teams.helpers({
theTeams: function () {
return Team.find({}).fetch();
},
players: function () {
var fullPlayerList = [];
this.players.forEach(function (p) {
fullPlayerList.push(p);
});
return fullPlayerList;
}
});
}