Meteor-session-bind

Two way data bindings between Meteor session variables and handlebars template html forms. Forked from nikhilbobb/Meteor-session-bind for Meteor 0.9.x compatibility.

Install

meteor add lsm:session-bind

Requires Meteor version >= 0.9.3

Basic Usage

In your javascript just add the following to the target template:

sessionBind(Template.hello);

And then in your handlebars template to bind a form element to the session variable seshVar:

<input type="text" {{bindSession "seshVar"}}>

The helper generates an id and keeps the value up to date, so you should not set either on your element. To set a default value on the input just do the following before template rendering:

Session.set("seshVar", "default text")

The helper has been tested with input tags (range, text, checkbox, and number), as well as select and textarea tags. It does not work with radio buttons (file an issue if that is something you need).

See examples in the test file here.

Advanced Usage

If you want to keep your session namespace clean then you can bind to a session object instead of a variable:

<input type="text" {{bindSession "seshVar" "seshObj"}}>

Then to get back the var:

var obj = Session.get("seshObj");
obj.seshVar; //is your variable

This is especially useful when you have multiple forms, as you can come up with an object per form.

##Problems

This is early software. Feel free to file an issue. I will deal with it as soon as I have time.

##Credits

Inspired by Meteor-handlebar-bind