BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.
http://www.jsviews.com
MIT License
2.68k stars 340 forks source link

No way to do deep observations with dynamic paths #304

Closed therik closed 8 years ago

therik commented 8 years ago

Hello, I'm trying to do:

{^{for county.results.county[~context.countyId]}} and it doesn't update on observable update:

$.observable(templateData).setProperty('county.results.county.CZ020', newDataFromAjax)

It seems that I should use something like {^{for county.results.county^[~context.countyId]}} in the tempalte yet the syntax doesn't allow that.

I added extra dummy layer to the object tree, so I iterate through fixed-name property: {^{for county.results.county[~context.countyId].content}}

That seems to have fixed it.

Is there a better way?

edit: the title is not correct, I don't really know where the problem is.

BorisMoore commented 8 years ago

Can you create a jsfiddle with what you are trying to do? But I will be away travelling for the next two weeks, so will not be able to follow up with help until after Sept 10th.

BorisMoore commented 8 years ago

I am back from travelling. If you still have a problem/question, can you create a jsfiddle so I can understand what you mean by a dummy layer added to the object tree, etc. and see more clearly what you are trying to do, and how you are setting it up.

Otherwise, we should close this issue...