Skip to content

Commit

Permalink
Ensure template data context is setup on re-renderings. (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslagle committed Oct 28, 2014
1 parent d1a8cbf commit f972a3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/reactive_table.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template name="reactiveTable">
{{setup}}
{{#if showFilter}}
<div class="form-group reactive-table-filter">
<div class="input-group col-sm-4 col-sm-offset-8">
Expand Down
16 changes: 15 additions & 1 deletion lib/reactive_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var getDefaultTrueSetting = function (key, templateData) {



Template.reactiveTable.created = function () {
var setup = function () {
this.data.settings = this.data.settings || {};
var collection = this.data.collection || this.data.settings.collection || this.data;

Expand Down Expand Up @@ -206,6 +206,14 @@ Template.reactiveTable.created = function () {

this.data.useFontAwesome = getDefaultFalseSetting('useFontAwesome', this.data);
this.data.showColumnToggles = getDefaultFalseSetting('showColumnToggles', this.data);
this.data.setup = true;
};

Template.reactiveTable.created = setup;
Template.reactiveTable.rendered = function () {
if (!this.data.setup) {
setup.call(this);
}
};

Template.reactiveTable.getPageCount = function () {
Expand All @@ -218,6 +226,12 @@ Template.reactiveTable.getPageCount = function () {

Template.reactiveTable.helpers({

'setup' : function () {
if (!this.setup) {
setup.call(Template.instance());
}
},

'getField': function (object) {
var fn = this.fn || function (value) { return value; };
var key = this.key || this;
Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: "A reactive table designed for Meteor",
version: "0.5.0",
version: "0.5.1",
name: "aslagle:reactive-table",
git: "https://github.com/ecohealthalliance/reactive-table.git"
});
Expand Down

0 comments on commit f972a3c

Please sign in to comment.