Skip to content

Default option not selecting #146

@yanickrochon

Description

@yanickrochon

First, this is a very nice plugin!

And here's the issue that I'm having. I have the widget created with these options :

$("#selectElement").selectBoxIt({
    theme: "jqueryui",
    autoWidth: false,
    nativeMousedown: true,
    defaultText: "Select an option"
});

The element looks like this

<select id="selectElement">
    <option value="1">One</option>
    <option value="2">Two</option>
</select>

The problem is that the first option is already selected (but is not shown as the default text is displayed) and when selecting it, the "change" event is never fired. To actually fire an even for the first option, I need to select the second option, then select the first option. However this is problematic as there must be only one event that needs to be fired.

I could trick this by inserting an empty option and adding showFirstOption: false. But if the expected behaviour could happen, it would be preferable.

Edit

I just saw the option-click event, would it break anything if this event would become an alias to the change event? To me, this is essentially the same. Or at least if a default text is showing and is replaced by the option value. Just a thought.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions