Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#8738 closed bug (worksforme)

Spinner does not fire change event.

Reported by: dsargent@… Owned by:
Priority: minor Milestone: 1.10.0
Component: ui.spinner Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

The API states that the spinner should fire the change event when it looses focus, as far as I can tell, it does not do so. Furthermore, I believe it should fire the change vent when it changes (on after arrow click for example), or at least that this should be an option. Example here: http://jsfiddle.net/xUNCH/

I'm attempting to use spinner with KnockoutJS, because the change event is not getting triggered my observable in the viewModel is not getting updated and therefore data is not getting changed. This makes spinner useless with any libraries that utilize this behavior.

Change History (10)

comment:1 Changed 6 years ago by Scott González

Resolution: worksforme
Status: newclosed

It trigger the spinner's change event, which has an event type of spinchange. The new documentation site doesn't currently include the event types, but we're working on that: https://github.com/jquery/api.jqueryui.com/issues/47

comment:2 Changed 6 years ago by dsargent@…

I guess I'm not understanding. The sample on jsFiddle I included clearly doesn't work. If a custom change event is the only thing it fires, how am I suppose to get that to work with KncokoutJS?

To fix my issue I've edited my local jQueryUI 1.9.1, line 10824 in the _value: event, adding the following towards the bottom.

this.element.change();

Full _value function

update the value without triggering change _value: function( value, allowAny ) {

var parsed; if ( value !== "" ) {

parsed = this._parse( value ); if ( parsed !== null ) {

if ( !allowAny ) {

parsed = this._adjustValue( parsed );

} value = this._format( parsed );

}

} this.element.val( value ); this._refresh();

Added by Dave Sargent dsargent to fix KnockoutJS observable not changing issue.

this.element.change();

},

comment:3 Changed 6 years ago by Scott González

This is not the place to ask for help with KnockoutJS integration. Please use the forums or StackOverflow.

comment:4 Changed 6 years ago by dsargent@…

Wow, how amazingly unhelpful of you. If you want your users to actually help you try and improve jQuery UI I suggest you try not being so rude when they do so. It's really unprofessional.

What I'm trying to explain is that as a developer, I would expect that the value of the text box changing would cause the change event to fire. This is how the DOM is supposed to work. The spinner doesn't do that, I call that a bug. Period.

I then ask you how it's supposed to work and get a pissy response, very uncool.

comment:5 Changed 6 years ago by Corey Frang

I'm pretty sure he wasn't being pissy. This is our bug tracker, not a support forum. Please check with the forums, IRC, StackOverflow, etc.

Last edited 6 years ago by Corey Frang (previous) (diff)

comment:6 Changed 6 years ago by ryanneufeld

FYI, The spinner (as most jquery ui widgets do) as several of it's own events that you can bind to.

For example: http://api.jqueryui.com/spinner/#event-change

Unless I'm mistaken, that's a change event. Enjoy :)

If you find any problems with this event. Please feel free to file another bug report. Alternatively you can use the forum and our very active IRC channels for help.

Thank-you for your contribution.

Last edited 6 years ago by ryanneufeld (previous) (diff)

comment:7 Changed 6 years ago by dsargent@…

Ryan, thank you that was a very nice response. I got it working, here's a sample: http://jsfiddle.net/afFh5/

But again, this ticket wasn't about me getting help getting this to work, which I agree this is not the place, but about what I feel is the bug that when the text is changed the main DOM change event for that textbox is not fired. i.e. I shouldn't have to subscribe to a specific jQuery UI change even when there already is one for the textbox which appears to be blocked. I guess there is some reason as to why you want to do this? If so, that would be a GREAT addition to the documentation.

comment:8 Changed 6 years ago by Scott González

Sure, we can add a note about this in the documentation. We'll need to add it to every widget that builds on form elements.

https://github.com/jquery/api.jqueryui.com/issues/63

comment:9 Changed 6 years ago by dsargent@…

Scott, thank you, that would be helpful. One other suggestion is to have examples for in the examples area that show how to use the events. To my knowledge there aren't any there for any of the widgets and I'm thinking it's probably one of the bigger stumbling blocks for newer JS developers. Also, can you answer my question as to why the built in change event isn't fired? Is it a design decision? Where there tough technical challenges etc.? I think explaining int he docs as to why would save allot of frustration.

Thanks again.

comment:10 Changed 6 years ago by Scott González

It's a design decision. We don't want to guarantee native functionality for enhanced widgets. It's a pain to do and generally not very useful. The meaning of the native change event is in fact preserved, as we don't do anything to prevent it. It never fires because the value is set programmatically, not by the user.

As for examples of events, they're coming. You'll notice we've already got the example for options added, methods are on their way, and events will come after that.

Note: See TracTickets for help on using tickets.