Uploaded image for project: 'ZK CKeditor'
  1. ZK CKeditor
  2. ZKCK-45

Ckez uses jQuery 1.7 functions, not compatible with ZK 5/6

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 4.11.1.1
    • 4.7.0.0, 4.11.1.0
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      run code with ZK 6.5.9.FL.20160314-Eval or lower and ckez 4.7.0.0 or higher

      <zk>
      	<ckeditor></ckeditor>
      </zk>
      
      

      Current Result

      JS console throw an error

      ckez.wpd:1513 Uncaught TypeError: jq(...).contents(...).on is not a function
          at a.<anonymous> (ckez.wpd:1513)
          at ckez.wpd:1197
      

      Expected Result

      ckez should work on zk5 + without error messages

      Debug Info

      https://github.com/zkoss/zkckeditor/blob/master/ckez/src/archive/web/js/ckez/CKeditor.js#L331
      caused by undefined jQuery .on() in ZK 6

      Root Cause

      zk 6 uses jQuery 1.6.4
      jQuery on() was introduced in 1.7

      Workaround

      For 4.11.1.0

      <script><![CDATA[ 
      	zk.afterLoad('ckez', function() {
      		var xCKeditor = {};
      		zk.override(ckez.CKeditor.prototype, xCKeditor ,{
      			_init: function() {
      		        if (!this.desktop || this._unbind)
      		            return;
      		        var wgt = this
      		          , uuid = this.uuid
      		          , dtid = this.desktop.id
      		          , customConfigPath = this._customConfigurationsPath
      		          , filebrowserBrowseUrl = this.filebrowserBrowseUrl
      		          , filebrowserImageBrowseUrl = this.filebrowserImageBrowseUrl
      		          , filebrowserFlashBrowseUrl = this.filebrowserFlashBrowseUrl
      		          , filebrowserUploadUrl = this.filebrowserUploadUrl
      		          , filebrowserImageUploadUrl = this.filebrowserImageUploadUrl
      		          , filebrowserFlashUploadUrl = this.filebrowserFlashUploadUrl
      		          , fileBrowserTempl = this.fileBrowserTempl
      		          , fileUploadTempl = this.fileUploadTempl
      		          , config = this.getConfig_({
      		            customConfig: customConfigPath,
      		            width: this._getValue(this._width),
      		            height: this._getValue(this._height)
      		        });
      		
      		        if (this._config) {
      		            zk.override(config, {}, this._config);
      		        }
      		
      		        if (filebrowserBrowseUrl)
      		            config.filebrowserBrowseUrl = fileBrowserTempl + '?Type=Files&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (filebrowserImageBrowseUrl)
      		            config.filebrowserImageBrowseUrl = fileBrowserTempl + '?Type=Images&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (filebrowserFlashBrowseUrl)
      		            config.filebrowserFlashBrowseUrl = fileBrowserTempl + '?Type=Flash&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (filebrowserUploadUrl)
      		            config.filebrowserUploadUrl = fileUploadTempl + '?Type=Files&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (filebrowserImageUploadUrl)
      		            config.filebrowserImageUploadUrl = fileUploadTempl + '?Type=Images&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (filebrowserFlashUploadUrl)
      		            config.filebrowserFlashUploadUrl = fileUploadTempl + '?Type=Flash&dtid=' + dtid + '&uuid=' + uuid;
      		
      		        if (this._toolbar)
      		            config.toolbar = this._toolbar;
      		
      		        var cnt = this.$n('cnt');
      		        jq(cnt).text(this._value);
      		
      		        jq(cnt).ckeditor(function() {
      		            if (wgt._unbind) {
      		                this.destroy();
      		                return;
      		            }
      		            wgt._editor = this;
      		            this.on('focus', ckez.CKeditor.onFocus);
      		            this.on('blur', ckez.CKeditor.onBlur);
      		            this.on('selectionChange', ckez.CKeditor.onSelection);
      		            wgt._overrideFormSubmit();
      		            this.on('key', ckez.CKeditor.onAutoHeight);
      		            this.on('loadSnapshot', ckez.CKeditor.onAutoHeight);
      		            this.on('beforePaste', ckez.CKeditor.onAutoHeight);
      		            this.on('maximize', ckez.CKeditor.onMaximize);
      		
      		            jq('iframe', this.container.$).contents().click(wgt.proxy(wgt._mimicOnClick));
      		            this.resetDirty();
      		
      		            if (!wgt._tmpHflex && wgt._hflex) {
      		                wgt._tmpHflex = wgt._hflex;
      		                wgt.setHflex(null);
      		            }
      		            if (!wgt._tmpVflex && wgt._vflex) {
      		                wgt._tmpVflex = wgt._vflex;
      		                wgt.setVflex(null);
      		            }
      		
      		            if (wgt._tmpHflex) {
      		                wgt.setHflex(wgt._tmpHflex, {
      		                    force: true
      		                });
      		                wgt._tmpHflex = null;
      		            }
      		            if (wgt._tmpVflex) {
      		                wgt.setVflex(wgt._tmpVflex, {
      		                    force: true
      		                });
      		                wgt._tmpVflex = null;
      		            }
      		        }, config);
      		
      		    }
      		});//zk.override
      	});//zk.afterLoad
      	]]></script>
      

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h