Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4932

Datebox with constraint sending unnecessary onChange Event

XMLWordPrintable

      Steps to Reproduce

      <zk>
          <datebox id="db" format="MM/dd/yyyy"
                   constraint="no empty"
                   onCreate="self.setValue(new Date());"
                   onChange=""/>
          <datebox id="dbConstraint" format="MM/dd/yyyy"
                   constraint="between 21000101 and 19000101"
                   onCreate="self.setValue(new Date());"
                   onChange=""/>
      </zk>
      

      focus either Datebox without changing the value
      leave(blur) Datebox again

      Current Result

      an onChange event with the initial unchanged value is sent to the server
       

      Expected Result

      only send onChange when the value was changed
       

      Debug Information

      the constraint sets a flag this._reVald which triggers the revalidation failing to recognize the value is still unchanged

      ZK-658
      tomyeh added a comment - 13/Dec/11 4:46 PM

      Notice if the constraint property is also specified, onChange is always fired.
      Reason: [spec] if constraint is specified, the first onblur will cause the input to re-validate.

      https://sourceforge.net/p/zk1/bugs/838/
      In this fix, the event will be consumed and onChange won't be called.
       

      Workaround

      suppress update/validation logic for unchanged input value

      zk.afterLoad('zul.db', function() {
          var xDatebox = {};
          zk.override(zul.db.Datebox.prototype, xDatebox, {
              updateChange_ : function() {
                  if(this.getInputNode().value === this._defRawVal) {
                      return false;
                  }
                  return xDatebox.updateChange_.apply(this, arguments);
              }
          });//zk.override
      });//zk.afterLoad
      
      

       

            rudyhuang rudyhuang
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 6 hours Remaining Estimate - 2 hours
                2h
                Logged:
                Time Spent - 6 hours Remaining Estimate - 2 hours
                6h