Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Selectmenu does not reflect script changes to select menu (changing selected item)! #270

Closed
brunis opened this Issue · 15 comments

2 participants

@brunis

Demo using setTimeout to change selected item in first dropdown after 1 second. Selected Item is changed but selectmenu is not registering it!
http://jsbin.com/iruvug/4/edit

@fnagel
Owner

Please take a look at the wiki how to set value and index correct.

@brunis

Please understand that selectmenu() does not register onchange event, the examples on the wiki do not work.

If i change the underlying select, i would expect selectmenu() to register it, regardless of how it was changed, script, mouseclick or divine intervention!

[edit]Also one thing to notice is that the selected item actually changes in the list! Just not the one visible[/edit]

@fnagel
Owner
@brunis

Adding a change EventListener does not poll constantly and is the foundation of DOM events.

Either i'm not explaining myself correctly or you are misunderstanding my explanation. Let me rephrase:

The SelectMenu (your ui widget), correctly changes the selected item according with my script changes to the original html .. it's just not showing it without opening it.

@fnagel
Owner

It wont work, try for yourself.

I talked to Jörn and Scott from jQuery UI a few month ago and we even will not implement it in the official Selectmenu.

@fnagel
Owner

I just checked my notes. Jörn said its not possible because we have no propertychange events consistency across the browsers. So we need to pull manually (setIntervall, timeout) in order to make this work.

Hope thats helps to make this more clear.

@brunis

Yes, that explains it alot better than the wiki.

Could you add to the wiki that it doesn't work with scripts and events then?

And remove this example (since it has no effect):
$('select').selectmenu({
change: function(e, object){
alert(object.value);
}
});

@brunis

Ok, i'll try again, since i'm positive that it can work regardless of your notes and whoever! if i could attach a screenshot i could show you that it works already, you just need to update the text in the span ..

  1. Go to this page: http://jsbin.com/iruvug/5/
  2. Wait 1 second
  3. Open the first "default popup" dropdown.
  4. Notice that the selected item has changed by my script, as expected!
  5. Realize that you already succesfully register the onchange event of the underlying select!
  6. Realize that you just forget to update the text in Slow
  7. Fix the bug! Please!
@fnagel
Owner

I could add a hint. What do you think of?

Wait a second. Your code snippet should work. Please test http://jsfiddle.net/fnagel/GXtpC/709/

Please understand that I maintain this code but Im not the original developer and a bunch of people contributed to this code. Its not really straight forward and Im not aware of all parts of the code ;-)

Im not really register a onChange event, the option text of the selectmenu is only correct because I get it from the current selected, native option. Its more a bug than a feature :-)
Im sorry, as long we do not have a way to register a cross browser onChange event its not possible. Why not using the API (see my example above)?

http://fiddle.jshell.net/fnagel/GXtpC/711/show/light/

@brunis

Thx for the tips, but you're just re-suggesting what's on the wiki and it doesn't work ..

Changing the select with a script does NOT fire the change event!

I'll have a look at the code if i get the time, this is certainly getting us nowhere!

Thanks for trying Felix!

@fnagel
Owner

Changing the native select does not work.. And it will never do. Thats what I said multiple times.

What I suggested (and you already posted) does work for sure, just see my fiddle: http://jsfiddle.net/fnagel/GXtpC/709/

@brunis

i did, it doesn't .. here's my version with the script changing the selected item

http://jsfiddle.net/GXtpC/713/

notice when you open it, it changed the value for you .. but no alerts !

@fnagel
Owner

It wont work when changing the native select. How often should I repeat this sentence?

Problem is the provided method wont do the trick either: http://jsfiddle.net/GXtpC/714/
Ive pushed a fix, please download latest commit and give feedback!

@brunis

You wont have to repeat it again, if you manage to fix that bug.

I can't wait to see if this fixes things for me!

[edit]Sorry, still a nogo, if this http://jsfiddle.net/GXtpC/715/ always uses latest version from GitHub? that can be your unit test, dropdown should change to Faster when it works :) You're changing the selected item, so you know it works! You just have to update the label on the selectmenu! [/edit]

@fnagel
Owner

Yes, its updated every 15min.

jsfiddle /715 still changes the native select. That will not work.
Im not able to fire the change callback event as Im not able to track the change event on the native select. Just changing the text does not make it work. See here again: #270 (comment)

Please debug it yourself if you wont believe.

@fnagel fnagel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.