Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support data-link binding back to a simple array of strings #53

bluefox opened this Issue · 8 comments

3 participants


JsViews seems to work fine when binding data from a simple array with #data (which basically is a short cut to access the data attribute directly.) However, this doesn't work when the array item has been updated in an input, since jsviews try to trigger setProperty on a simple property. Results in changes not reflected to the original array.


I haven't understood quite what you mean. Can you show a sample page - as simple as possible, but showing what you mean by 'an array item being updated in an input? Or a sample on jsfiddle...


Hi Boris,
I'm having, what I understand to be, the same issue, so I'll hijack this post and try to provide a bit more color.

Data linking seems to work fine when I have an array of objects:

{{for titles}}
<input data-link="value" /><br>

var titles = [ { "value" : "Princess Bride"}, { "value" : "Moonraker" } ];

But if it's a "simple" array, only the render works, but updates aren't reflected in the original array.

{{for titles}}
<input data-link="#data" />

var titles = [ "Princess Bride", "Moonraker" ];



OK, great, thanks. I follow the issue now. Yes, observable changes are built on property changes of objects, or collection changes for arrays. Here if the array is an array of strings, or numbers, say, then the way the view is correctly updating, is by considering the change as a change in the "data" property of the view. (Whereas for the value property of a data object, it would be tracking the value property of the data object,)

For the moment JsViews doesn't support pushing those changes automatically back to the array of strings. It may become supported (I'll keep this issue open). But until then it would be best to use an array of objects. Worst case scenario, if for some reason you can't do that, would be to write code to take the value of of each view, and copy it back to your array.


Thanks for the quick response. I was able to wrap my array elements in a simple value object and now it works.
I'm having a similar issue, however, with updates being reflected when making use of iteration over fields in an object:

Looking at your example of field iteration:

If you update "details" and add the "director" property to "Eyes Wide Shut", for example, the change is not reflected in the display (the new property does appear if you inspect the JSON object).

Is there way to say "loop again"?


Got it to work by calling view.render();


Heads up that the method is now called view.refresh().


Already using it :)


Closing "After V1.0" issues for now - to reopen as appropriate.

@BorisMoore BorisMoore closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.