BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

simple dynamic data-link value #345

Closed ethar1 closed 8 years ago

ethar1 commented 8 years ago

Dear Boris, Thanks for your great work "jsviews" , I like it so much ... could you please tell me why this not working?

{{props #data}}
<span>{{:key}} :</span>: <input data-link="{{:key}} trigger=true">
{{/props}}

I already know about http://jsfiddle.net/BorisMoore/hqy06tm5/ but its very cokplecated for my case, my case not a full dynamic... Thanks

BorisMoore commented 8 years ago

Hi Ethar, If you look at the third sample of http://www.jsviews.com/#jsvpropstag you have this:

{^{props members}}
  <li>
    <input data-link="prop"/>
    {^{>prop}} ...
  </li>
  ...

In your case

{{props #data}}
<span>{{:key}} :</span>: <input data-link="prop">
{{/props}}

should work fine - for dynamically changing the property value.

As explained in that topic:

Inside the {^{props members}} tag, a block is rendered for each property, with as data context:

{key: propertyName, prop: propertyValue} – so {{>key}} gives the key and {{>prop}} gives the value for that property.

Within the {^{props}} the current data item is an object

In your code you have <input data-link="{{:key}} trigger=true"> which will render as <input data-link="keyValue trigger=true"> - but the current context is not the outer #data object, so that will not work.

ethar1 commented 8 years ago

Thank you very much it work as expected...