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
    ing.amdangelo is on a distinguished road

      0  

    Default Spinnerfield don't fire the Change Event

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1