Skip to content

Commit

Permalink
Merge pull request #12 from hanhsu/refix-B70-CKEZ-#9
Browse files Browse the repository at this point in the history
refix Issue #9: unexpected onChange event after setting the value from t...
  • Loading branch information
hanhsu committed Oct 16, 2014
2 parents 93dcefb + 6e41756 commit c29ae27
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ckez/src/archive/web/js/ckez/CKeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ ckez.CKeditor = zk.$extends(zul.Widget, {
var editor = this.getEditor();
if (editor) {
editor.setData(v);
// Issue #9: update editor's previousValue if set value from server
// Issue #9 refix: update editor's previousValue if set value from server
// to prevent unexpect onChange event
if (fromServer)
editor._.previousValue = v;
editor._.previousValue = editor.dataProcessor.toHtml(v);
}
}],
autoHeight: null,
Expand Down
37 changes: 19 additions & 18 deletions test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<zk>
<zscript>
String myValue = "initial value";
public updateMyValue(String newValue) {
myValue = newValue;
editor.setValue(myValue);
//Clients.showNotification("updated myValue to: " + myValue);
}
</zscript>
<vlayout>
<button label="1. update editor value to 'abc'" onClick='updateMyValue("&lt;p&gt;abc&lt;/p&gt;");' />
<button label="2. update editor value to 'XYZ'" onClick='updateMyValue("&lt;p&gt;XYZ&lt;/p&gt;");' />
<button label="3. do something unrelated and show 'myvalue'"
onClick='debugLabel.setValue("myValue: " + myValue);' />
<label id="debugLabel" />
<ckeditor id="editor" value="${myValue}" onChange='myValue = self.getValue(); alert("changed")' />
</vlayout>
</zk>
<zk>
<zscript>
String myValue = "initial value";
public updateMyValue(String newValue) {
myValue = newValue;
editor.setValue(myValue);
//Clients.showNotification("updated myValue to: " + myValue);
}
</zscript>
<vlayout>
<button label="1. update editor value to 'abc'" onClick='updateMyValue("abc");'/>
<button label="2. update editor value to 'XYZ'" onClick='updateMyValue("XYZ");'/>
<button label="1-1 update editor value to 'abc' with p tag" onClick='updateMyValue("&lt;p&gt;abc&lt;/p&gt;");' />
<button label="2-1 update editor value to 'XYZ' with p tag" onClick='updateMyValue("&lt;p&gt;XYZ&lt;/p&gt;");' />
<button label="3. do something unrelated and show 'myvalue'" onClick='debugLabel.setValue("myValue: " + myValue);'/>
<label id="debugLabel"/>
<ckeditor id="editor" value="${myValue}" onChange='myValue = self.getValue(); Clients.showNotification("Triggered onChange");'/>
</vlayout>
</zk>

0 comments on commit c29ae27

Please sign in to comment.