Search and Top Navigation
#8738 closed bug (worksforme)
Opened October 26, 2012 05:18PM UTC
Closed October 26, 2012 05:29PM UTC
Last modified October 29, 2012 06:27PM UTC
Spinner does not fire change event.
Reported by: | dsargent@gmail.com | 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:
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.
Attachments (0)
Change History (10)
Changed October 26, 2012 05:29PM UTC by comment:1
resolution: | → worksforme |
---|---|
status: | new → closed |
Changed October 26, 2012 05:38PM UTC by comment:2
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();
},
Changed October 26, 2012 05:39PM UTC by comment:3
This is not the place to ask for help with KnockoutJS integration. Please use the forums or StackOverflow.
Changed October 26, 2012 05:43PM UTC by comment:4
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.
Changed October 26, 2012 06:01PM UTC by comment:5
_comment0: | I'm pretty sure he wasn't being pissy, but this is our bug tracker, not a support forum. Please check with the forums, IRC, StackOverflow, etc. → 1351274486820580 |
---|
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.
Changed October 26, 2012 06:21PM UTC by comment:6
_comment0: | 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 have any more trouble with this event. Please feel free to file another bug report. \ \ Thank-you for your contribution. → 1351275745685440 |
---|
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.
Changed October 26, 2012 08:16PM UTC by comment:7
Ryan, thank you that was a very nice response.
I got it working, here's a sample:
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.
Changed October 26, 2012 08:20PM UTC by comment:8
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.
Changed October 26, 2012 09:17PM UTC by comment:9
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.
Changed October 29, 2012 06:27PM UTC by comment:10
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.
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