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

Missing refresh in template after value change #125

Closed
divdavem opened this issue Apr 10, 2014 · 2 comments
Closed

Missing refresh in template after value change #125

divdavem opened this issue Apr 10, 2014 · 2 comments
Labels

Comments

@divdavem
Copy link
Member

Plunk

Here is the plunk to reproduce this issue: http://embed.plnkr.co/YmP8EW8ARdsjIDcvk5bc
(and also http://embed.plnkr.co/9paCyklH88XvwvS1cSOk)

Go to page 2 and click on "Change value".

HSP file

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

var Tab = klass({
    $constructor : function () {
        this.changeValue();
    },
    changeValue: function () {
      this.value = new Date().getTime();
    }
});

# template displayObject(value)
  Value: {value} (through template)<br>
# /template

var Ctrl = klass({
    $constructor: function () {
        this.activeTab = new Tab();
        this.tabs = [this.activeTab,new Tab()];
    },
    clickTab: function (event,tab) {
        event.preventDefault();
        this.activeTab = tab;
    }
});

# template main using controller:Ctrl
    <ul class="nav nav-tabs">
        {foreach index,tab in controller.tabs}
            <li class="{'active': controller.activeTab === tab}">
            <a href="#" onclick="{controller.clickTab(event,tab)}">
                Page {index+1}
            </a>
            </li>
        {/foreach}
    </ul>
    Value: {controller.activeTab.value} (direct)<br>
    <#displayObject value="{controller.activeTab.value}"/><br>
    <button onclick="{controller.activeTab.changeValue()}">Change value</button>
# /template

main().render(document.body);

Expected behavior

When clicking on "Change value" on page 2, the value should be updated in both places (both in direct display and through template), just like on page 1.

Actual behavior

When clicking on "Change value" on page 2, only the direct display is updated. The value displayed through the displayObject template is not refreshed until the active tab changes.

Hashspace version

Tested with commit d692180.

@divdavem divdavem added the bug label Apr 10, 2014
@divdavem
Copy link
Member Author

This issue seems to be similar to #26 (which was fixed by #81 and #103 through the call of updateObjectObservers).
The problem in #26 was about text nodes, the issue is now is about template attributes:
it looks like listeners are not added to the new tab after the activeTab property changes.

@divdavem
Copy link
Member Author

this.adirty = false in $root.js, line 507 seems wrong (especially when considering the comment in tnode.js, line 210).
But removing this line makes other tests fail (cf my branch issue125 and the corresponding travis build).

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

No branches or pull requests

1 participant