Gridster add_widget with Meteor -
i have troubles wihth gridster & meteor. @ first, loaded whole widgets template , recalculate grid method below.
i have template named dashboard, in template loop through widgets , call second template called widgettmpl contains formatted html
<template name="dashboard"> <div id="dashboardbody"> <button id="configmode" class="btn btn-primary"> <i class="fa fa-pencil"></i>configuration </button> <div class="gridster"> <ul id="widgetitemlist" class="widget_item"> {{#each activewidgets}} {{> widgettmpl}} {{/each}} </ul> </div> </div> </template>
i execute code callback onrendered
template.dashboard.onrendered(function(){ var gridsterul = jquery(".gridster ul"); gridsterul.gridster({ widget_margins: [5, 5], widget_base_dimensions: [25, 25], resize : { enabled : true }, draggable: { start: overlay_fix_start, stop: overlay_fix_stop }, serialize_params : function($w, wgd){ return { id : $w.prop('id'), col : wgd.col, row : wgd.row, size_x : wgd.size_x, size_y : wgd.size_y }; } }); });
this works fine, when add or reload widget, have refresh page due onredered callback.
i heard gridster.add_widget methods, perfect job don't know how implement code. should use gridster.add_widget ?
there methods blaze.insert , blaze.renderwithdata have no idea how use it
i've never tried using gridster, have integrated d3 quite few of meteor apps. when want d3 context reactivity change without page refresh, use tracker.autorun
in onrendered
callback reactive datasource. example simplified code this:
template.d3plot.onrendered( function () { tracker.autorun(function() { // function draws , redraws due tracker , reactive data drawplot(plots.find()); }); }); drawplot = function (plotitems) { ..... }
where plots
mongo collection whenever new item inserted/updated in collection, drawplot
function re-fires.
Comments
Post a Comment