onChange

срабатывает при изменении значения контрола

void onChange(any newValue,any oldValue, [any config] );
newValueanyновое значение
oldValueanyпредыдущее значение
configanyисточник изменения значения

Example

$$("control").attachEvent("onChange", function(newValue, oldValue, config){
    webix.message(
      `Value changed from ${oldValue} to ${newValue}. Source: ${config}`
    );
});

Related samples

Details

The config parameter can have the following values:

  • "user" - if the change was made by user
  • "auto" - if the change was made by the library inner logic
  • undefined - if the change was made by a control's setValue or Form setValues method call made by a programmer.

Also, you can get a custom value as the config parameter. To do that call the setValue/setValues method passing your value as the last argument:

webix.ui({
  view:"switch",
  // ..config
  on:{
    onChange: function(newValue, oldValue, config){
        // config is {yourProperty: "yourValue"}
    }
  }
});
 
// onChange event will receive object as the 3rd parameter
$$("$switch1").setValue(newValue, {yourProperty: "yourValue"});
See also
Наверх