Skip to content

Commit

Permalink
Merge pull request #10 from hanhsu/B70-CKEZ-#9
Browse files Browse the repository at this point in the history
Fix Issue #9: unexpected onChange event after setting the value from the...
  • Loading branch information
hanhsu committed Oct 9, 2014
2 parents fb162a1 + eba7b53 commit 93dcefb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ckez/src/archive/web/js/ckez/CKeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ ckez.CKeditor = zk.$extends(zul.Widget, {
$define: {
value: [function(v) {
return !v ? '' : v;
}, function (v) {
}, function (v, fromServer) {
var editor = this.getEditor();
if (editor)
if (editor) {
editor.setData(v);
// Issue #9: update editor's previousValue if set value from server
// to prevent unexpect onChange event
if (fromServer)
editor._.previousValue = v;
}
}],
autoHeight: null,
customConfigurationsPath: _zkf = function () {
Expand Down
18 changes: 18 additions & 0 deletions test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<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>
3 changes: 2 additions & 1 deletion test/addon/ckeztest/src/archive/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ B65-CKEZ-20.zul=Ckeditor,onChange
B70-CKEZ-23.zul=Ckeditor,onChange
B70-CKEZ-22.zul=Ckeditor,FileUpload
B70-CKEZ-5.zul=Ckeditor,onSize
B70-CKEZ-7.zul=A,E,Ckeditor,onChanging,FireEvent
B70-CKEZ-7.zul=A,E,Ckeditor,onChanging,FireEvent
B70-CKEZ-9.zul=A,E,Ckeditor,onChange,setValue
1 change: 1 addition & 0 deletions zkdoc/ckez-release-note
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Ckez 4.3.3.1
* Bugs:
Issue #5: textarea of zkeditor not resizing properly
Issue #7: onChanging event not fired since ZK CKEditor 4.x
Issue #9: unexpected onChange event after setting the value from the server

* Upgrade Notes:

Expand Down

0 comments on commit 93dcefb

Please sign in to comment.