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

Closed
brunis opened this Issue Oct 1, 2012 · 15 comments

Comments

Projects
None yet
2 participants
@brunis

brunis commented Oct 1, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 5, 2012

Owner

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

Owner

fnagel commented Oct 5, 2012

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

@brunis

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 5, 2012

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]

brunis commented Oct 5, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 5, 2012

Owner

Thats not possible without pulling for changes constantly. Which is very
expensive.

Please use the API as described in the wiki.

Owner

fnagel commented Oct 5, 2012

Thats not possible without pulling for changes constantly. Which is very
expensive.

Please use the API as described in the wiki.

@brunis

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 8, 2012

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.

brunis commented Oct 8, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 8, 2012

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.

Owner

fnagel commented Oct 8, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 8, 2012

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.

Owner

fnagel commented Oct 8, 2012

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

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 8, 2012

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 commented Oct 8, 2012

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

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 8, 2012

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!

brunis commented Oct 8, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 9, 2012

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/

Owner

fnagel commented Oct 9, 2012

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

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 10, 2012

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!

brunis commented Oct 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 10, 2012

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/

Owner

fnagel commented Oct 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 10, 2012

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 !

brunis commented Oct 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 10, 2012

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!

Owner

fnagel commented Oct 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@brunis

brunis Oct 10, 2012

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]

brunis commented Oct 10, 2012

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

This comment has been minimized.

Show comment Hide comment
@fnagel

fnagel Oct 12, 2012

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.

Owner

fnagel commented Oct 12, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment