Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing an intermediate object breaks bindings in one way #26

Closed
divdavem opened this issue Dec 31, 2013 · 2 comments
Closed

Changing an intermediate object breaks bindings in one way #26

divdavem opened this issue Dec 31, 2013 · 2 comments
Labels

Comments

@divdavem
Copy link
Member

Changing an intermediate object in the data model breaks bindings from the data model to the UI (bindings from the UI to the data model still work though).

HSP file

var json = require("hsp/json");

var changeObject = function(data) {
    json.set(data,"object",{value:new Date()+""})
};

var changeValue = function(data) {
    json.set(data.object,"value",new Date()+"")
};

var displayValue = function(data) {
    alert(data.object.value);
};

# template bindings(data)
    <input type="text" value="{data.object.value}" />
    <input type="text" value="{data.object.value}" /><br />
    <button onclick="{changeObject(data)}">Change object</button>
    <button onclick="{changeValue(data)}">Change value</button>
    <button onclick="{displayValue(data)}">Display value</button>
# /template

bindings({object:{value:"initial value"}}).render("output");

Expected behavior

As both fields are linked to the same value in the data model, both fields and the data model should always be synchronized, even when changing the intermediate object data.object.

Actual behavior

As long as we do not click on the "Change object" button, everything is synchronized as expected.
However, after clicking on "Change object", no listener seems to be is added to the new object, and changing the value by clicking on "Change value" no longer updates the display. Typing in one of the fields still updates the data model but does not update the other field.

Hashspace version

Tested with commit 930d7b8.

@PK1A
Copy link
Contributor

PK1A commented Mar 12, 2014

I remember that on one of the meeting this issue was discussed as potentially fixed. Unfortunately it seems it is still there: http://plnkr.co/edit/0FNxWVYzuyyDc1jxKLDP?p=preview

BTW: wanted to reproduce in plunker just to see how easy / hard it is to do, you can examine effects looking at the plunk, but IMO we need to improve this part.

b-laporte pushed a commit to b-laporte/hashspace that referenced this issue Mar 15, 2014
@b-laporte b-laporte mentioned this issue Mar 15, 2014
@divdavem
Copy link
Member Author

@b-laporte Thank you for the fix! It is working fine now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants