Skip to content

Problem retrieving correct val of a select #168

Closed
@nabil1337

Description

Hello,

there seems to be a bug since this commit:

7af40c0

The problem occurs, when trying to get the values of a select in Firefox. You can do it with jQuery's .val(), of course. If I select one or two elements and try to get the val() via jQuery, it works fine. But if I deselect them now and then select them again, .val() returns null.
That's because the selected-prop isn't set.

I created an example here:

http://jsfiddle.net/MrEGh/

  • open console
  • click "select two"
  • a click on "show vals" will show you the correct vals
  • click "deselect two"
  • click "select two"
  • a click on "show vals" will show null

The question is: Why did you replace .prop() with .attr() in the commit mentioned above? .prop is the best for live-updates, the attributes are mainly used for pre-set values. Also, afaik you can't pass a boolen to .attr() as second argument, as you should do with .prop().

With .prop() instead of .attr(), the fiddle works. Maybe you can use them both?

Again, thanks for your work.

Greets.

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions