Meteor Reactive Session: Not Working (Why?) -
i'm having trouble reactive sessions in meteor.js.
demo: meteor pad
template.rows.helpers({ 'rows': function () { return session.get('rows'); // data set in session } }); template.count.events({ 'click .mdl-radio__button': function (e) { // target represents number of selected rows (1, 2, 5, or 10) var value = $(e.currenttarget).val(); session.set('limit', value); }, 'click #reset': function () { session.set('limit', 0); session.set('rows', null); }, 'click #run': function () { // should rows when run() pressed session.set('rows', currentitems); } }); users should able select new number of collections receive, controlled limit. however, keep getting following error:
error: match error: failed match.oneof or match.optional validation
any ideas why? can show me working meteorpad demo?
i'm having trouble meteorpad. problem isn't session. problem usage of tracker.autorun. should read docs on that.
you assuming tracker.autorun(getitems) returns getitems returns. that's not case tough. you'll need set currentitems inside autorun (in case getitems).
getitems = function () { if (session.get('limit') > 0) { currentitems = items .find({}, {limit: session.get('limit')}) .map(function (item, index) { item.index = index + 1; return item; }); } else { currentitems = null; } };
Comments
Post a Comment