Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3575 closed feature (invalid)

select event for html select element

Reported by: stasikom Owned by: brandon
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc: stasikom
Blocked by: Blocking:

Description

Binding actions to a select element with dynamic option ammount is quite hard to implement. You never know, if there is going to be 1 or more options. I've been binding to the "change" event, which doesn't fire on one-option selects - effecting in hindering the desired behaviour.

Another problem is, when you have a select with options > 1, it tends to remember what has been selected. If further document behaviour depends on that selection, and the user wishes to keep it (not change it) - he can't fire the "change" event without in fact changing the selection, then selecting the desired option once again. It kind of breaks usability.

A "select"-like event for select elements would really help here. It should get fired once an option is clicked. Unfortunately, binding actions to "click" on option elements fails in IE.

Attachments (1)

index.html (5.6 KB) - added by stasikom 11 years ago.
test case

Download all attachments as: .zip

Change History (3)

comment:1 Changed 11 years ago by flesler

Cc: stasikom added
need: ReviewTest Case

The change event is THE way of doing that, it's perfectly usable.

Some browser do remember last selected option, what's the problem with that ?

Can you make a test case so I understand the situation ?

Changed 11 years ago by stasikom

Attachment: index.html added

test case

comment:2 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

I looked at the test case. The decision on whether to show the next step should depend on whether the current step is displaying the non-default selection, not simply whether the change event has fired. For example, if the user sets the value back to "choose something" in step 1, the value for step 2 is still showing even though it's not appropriate anymore.

In the .ready() handler you can use the pattern $("select").change(function(){ ... }).trigger("change") to make sure the values are set correctly when the page is reloaded.

Note: See TracTickets for help on using tickets.