Skip to content

Commit b4a1ef6

Browse files
author
Jelte Lagendijk
committed
Merge branch 'master' of ssh://github.com/rik-bos/HTMLSnippet into rik-bos-master
2 parents b393883 + a986e00 commit b4a1ef6

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/HTMLSnippet/HTMLSnippet.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,12 @@
5252
<category>Behavior</category>
5353
<description>Refresh when the context changes</description>
5454
</property>
55+
56+
<!-- Refresh when the context updates -->
57+
<property key="refreshOnContextUpdate" type="boolean" defaultValue="false">
58+
<caption>Refresh on context update</caption>
59+
<category>Behavior</category>
60+
<description>Refresh when the context updates (works only when context change is true)</description>
61+
</property>
5562
</properties>
5663
</widget>

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ require([
1616

1717
return declare("HTMLSnippet.widget.HTMLSnippet", [_WidgetBase], {
1818

19+
_objectChangeHandler : null,
20+
1921
postCreate: function() {
2022
this._setupEvents();
2123

@@ -74,7 +76,26 @@ require([
7476
update: function(obj, callback) {
7577
if (this.refreshOnContextChange) {
7678
this.executeCode();
79+
80+
if(this.refreshOnContextUpdate){
81+
82+
if (this._objectChangeHandler !== null){
83+
this.unsubscribe(this._objectChangeHandler);
84+
}
85+
86+
if (obj){
87+
88+
this.subscribe({
89+
guid: obj.getGuid(),
90+
callback: lang.hitch(this, function(){
91+
this.executeCode();
92+
})
93+
});
94+
}
95+
}
7796
}
97+
98+
7899
callback();
79100
},
80101

test/Test.mpr

30 KB
Binary file not shown.

test/widgets/HTMLSnippet.mpk

1.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)