You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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).
divdavem
added a commit
to divdavem/hashspace
that referenced
this issue
Apr 10, 2014
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
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.
The text was updated successfully, but these errors were encountered: