From eba7b53e05b5e49710e4435235b55e432849c2fb Mon Sep 17 00:00:00 2001 From: hanhsu Date: Thu, 9 Oct 2014 08:32:15 +0100 Subject: [PATCH] Fix Issue #9: unexpected onChange event after setting the value from the server --- ckez/src/archive/web/js/ckez/CKeditor.js | 9 +++++++-- .../ckeztest/src/archive/test2/B70-CKEZ-9.zul | 18 ++++++++++++++++++ .../src/archive/test2/config.properties | 3 ++- zkdoc/ckez-release-note | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul diff --git a/ckez/src/archive/web/js/ckez/CKeditor.js b/ckez/src/archive/web/js/ckez/CKeditor.js index 7f3a9521..7f82505a 100644 --- a/ckez/src/archive/web/js/ckez/CKeditor.js +++ b/ckez/src/archive/web/js/ckez/CKeditor.js @@ -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 () { diff --git a/test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul b/test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul new file mode 100644 index 00000000..633a6525 --- /dev/null +++ b/test/addon/ckeztest/src/archive/test2/B70-CKEZ-9.zul @@ -0,0 +1,18 @@ + + + String myValue = "initial value"; + public updateMyValue(String newValue) { + myValue = newValue; + editor.setValue(myValue); + //Clients.showNotification("updated myValue to: " + myValue); + } + + +