Last active
August 29, 2015 14:03
-
-
Save wizonesolutions/babb1a60e3bb850cb5b7 to your computer and use it in GitHub Desktop.
This file contains 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
Meteor.startup(function () { | |
Session.setDefault('__blocksRendered', false); | |
}); | |
// **************** SCHEDULES **************** // | |
Template.schedules.rendered = function () { | |
} | |
Template.schedule.rendered = function () { | |
var list = this.find('div.schedule__blocks'); | |
var $list = $(list); | |
$list.sortable(); | |
} | |
Template.schedules.schedules = function () { | |
var data = Schedules.find().fetch(); | |
return data; | |
} | |
// **************** BLOCKS ******************* // | |
Template.blocks.rendered = function () { | |
} | |
// Hate you, Blaze rendered callback | |
Deps.autorun(function () { | |
console.log('blocksSub ready: ' + blocksSub.ready()); | |
if (Session.equals('__blocksRendered', true)) { | |
var $list = $('.schedule-block-list'); | |
console.log($list.length); | |
$list.draggable({ | |
connectToSortable: '.schedule__blocks', | |
helper: "clone" | |
}); | |
} | |
}); | |
Template.block.rendered = function () { | |
if (blocksSub.ready()) { | |
Session.set('__blocksRendered', true); | |
} | |
} | |
Template.blocks.blocks = function () { | |
var data = Blocks.find().fetch(); | |
return data; | |
} | |
Template.block.formattedDuration = function () { | |
var duration = moment.duration(this.duration); | |
return duration.format('H:mm:ss'); | |
} |
This file contains 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
var _self = this; | |
if (Meteor.isClient) { | |
Deps.autorun(function () { | |
_self.schedulesSub = Meteor.subscribe('dayMeterSchedules'); | |
_self.blocksSub = Meteor.subscribe('dayMeterBlocks'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment