sshefer
sshefer

Reputation: 239

Dynamically Adding New Options to a Hash

Here's my silly question regarding jQuery that I should probably know. It's in regards to using jQuery and Handlebar templates.

I set a context hash in my code as follows (similar to the example @ http://www.handlebarsjs.com/):

context = {id: 1}

All I want to do is dynamically add some elements to that in a loop. I'm simply pulling some values from a form, setting them as variables, and adding them in using "field_name" and "field_input" for the aforementioned data.

I can't seem to find anything that works, tried append, push, etc. with no luck - what am I doing wrong?

Upvotes: 0

Views: 61

Answers (1)

Ilia G
Ilia G

Reputation: 10211

Access it as you would normal hash object

context["id"] = 1;

or simply

context.id = 1;

Upvotes: 2

Related Questions