diff --git a/.gitignore b/.gitignore
index 677a6fc..e1b0285 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,40 @@
-.build*
+.build
+*.lock
+*.swp
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+
+# Misc #
+############
+.svn
+
+# IDE #
+#######
+.settings
+.idea
diff --git a/lib/reactive_table.html b/lib/reactive_table.html
index c3f39d0..c9b3c5c 100644
--- a/lib/reactive_table.html
+++ b/lib/reactive_table.html
@@ -51,7 +51,7 @@
{{#each sortedRows}}
-
+
{{#each ../fields}}
{{#if tmpl}}{{#with ..}}{{> ../tmpl}}{{/with}}{{else}}{{getField ..}}{{/if}} |
{{/each}}
diff --git a/lib/reactive_table.js b/lib/reactive_table.js
index a1e83b6..9b66a0f 100644
--- a/lib/reactive_table.js
+++ b/lib/reactive_table.js
@@ -68,10 +68,12 @@ var generateSettings = function () {
};
cursor.observe({added: addedCallback, changed: changedCallback, removed: removedCallback});
} else {
- console.log("reactiveTable error: argument is not an instance of Meteor.Collection, a cursor, or an array");
+ console.error("reactiveTable error: argument is not an instance of Meteor.Collection, a cursor, or an array");
collection = new Meteor.Collection(null);
}
}
+ this._collection = this.collection;
+ this.collection = collection;
var fields = settings.fields || {};
if (_.keys(fields).length < 1 ||
@@ -179,6 +181,16 @@ Template.reactiveTable.getPageCount = function () {
return Math.ceil(count / rowsPerPage);
};
+Template.reactiveTable.rendered = function () {
+ var collection = this.data.collection;
+ $(this.findAll('tbody tr')).each(function () {
+ var $row = $(this);
+ var id = $row.attr('data-id');
+ var model = collection.findOne(id);
+ $row.data('model', model);
+ });
+};
+
Template.reactiveTable.helpers({
'generateSettings': generateSettings,
@@ -193,6 +205,10 @@ Template.reactiveTable.helpers({
return _.indexOf(fields, this);
},
+ 'getRowId': function () {
+ return this._id;
+ },
+
'getKey': function () {
return this.key || this;
},
@@ -304,7 +320,7 @@ Template.reactiveTable.events({
var group = $(event.target).parents('.reactive-table-navigation').attr('reactive-table-group');
Session.set(getSessionRowsPerPageKey(group), rowsPerPage);
} catch (e) {
- console.log('rows per page must be an integer');
+ console.error('rows per page must be an integer', e);
}
},
@@ -314,7 +330,7 @@ Template.reactiveTable.events({
var group = $(event.target).parents('.reactive-table-navigation').attr('reactive-table-group');
Session.set(getSessionCurrentPageKey(group), currentPage);
} catch (e) {
- console.log('current page must be an integer');
+ console.error('current page must be an integer', e);
}
},