Results 1 to 2 of 2

Thread: Spinnerfield don't fire the Change Event

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Maddaloni (CE) Italy
    Posts
    74
    Vote Rating
    1
      0  

    Default Spinnerfield don't fire the Change Event

    I'm tried and I follow the post ......

    I commented //Onblur:Empty
    and the last line of triggerOnBlur like suggested by post ....
    but don't change nothing

    on blur and on change doesn't fire ...

    Please suggest me how do correct the Bug

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,050
    Vote Rating
    1381
      0  

    Default

    Try this override:

    Code:
    Ext.override(Ext.ux.form.SpinnerField, {
        setRawValue: function(val) {
            var me  = this,
                old = me.getValue(),
                ret;
    
            if (me.fireEvent('beforechange', me, val, old) == false) {
                return;
            }
    
            ret = me.rendered ? (me.el.dom.value = (Ext.isEmpty(val) ? '' : val)) : '';
    
            me.fireEvent('change', me, val, old);
    
            return ret;
        }
    });
    I gave you two events, beforechange and change. If you return false in the beforechange, it will cancel the changing:

    Code:
        var form = new Ext.form.FormPanel({
            renderTo : Ext.getBody(),
            width    : 400,
            height   : 400,
            title    : 'Test',
            items    : [
                {
                    xtype      : 'spinnerfield',
                    fieldLabel : 'Spinner',
                    listeners  : {
                        beforechange : function(field, newValue, oldValue) {
                            return newValue <= 5 && newValue >= -5;
                        },
                        change : function(field, newValue, oldValue) {
                            console.log(newValue, oldValue);
                        }
                    }
                }
            ]
        });
    You can see in the beforechange listener it return true if newValue is less than or equal to 5 and greater than or equal to -5. If it attempts to change outside +/-5 it will return false and stop it. You can also see in the change listener you have access to the field, new and old values.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •