I don't want the value of my spinner to be updated when the user clicks on the up arrow. In the API says:
spin( event, ui )
Triggered during increment/decrement (to determine direction of spin compare current value with ui.value). Can be canceled, preventing the value from being updated.
But does not show an example of how to do it. I started a code like this:
var spinner = $( ".mySpinner" ).spinner({
min: 0,
spin: function( event, ui ) {
//don't know what to do!
}
});
How can I cancel the spin event?
Can you help me? Thank you!
Event cancellation in jQuery UI works the same way as for native DOM events.
You only have to call preventDefault():
var spinner = $( ".mySpinner" ).spinner({
min: 0,
spin: function( event, ui ) {
// Cancel the spin event. The value will not be updated.
event.preventDefault();
}
});
You can also return false
from the handler, however this not only cancels the event but effectively stops its propagation to ancestor elements, as if stopPropagation() was called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With