jquery-flexselect
jquery-flexselect copied to clipboard
Minor bug fixes
Line 108: Show results if picked option is blank. If a blank option was present, results would previously not show on focus.
Line 315:
Change setValue.val("");
to setValue("");
. This will now set original
select
's value to blank as intended.
Previously this would have no
effect and instead keep previously selected values.
Fixes issues #13 and #37.
This appears to break the general allowMismatch
usage. Testing it, it appears that it's now no longer possible to write in a custom mismatch value.
Apologies, forgot to copy over one more change from my own copy.
Also when retesting I noticed there's no setValue call onblur
when using a mismatch, so will add this too and update soon.
Ok, came to realise the method I used may not be suitable for all cases (I was simply setting the value to blank and not triggering the change event if allowMismatch
was true), so I've been trying to improve it a little. I've come into a couple issues... (this may be better suited in an issue thread, I'll open it if you prefer to discuss there).
-
In my particular case, I had a blank value, so using
setValue("")
was fine. But in cases where there is no blank value, the originalselect
would be set to the first option. This change event then causes the flexselect to update to the originalselect
value. -
From what I can tell,
allowMismatchBlank
is currently useless, within the settings there is the comment:allowMismatchBlank: true, //If "true" a user can backspace such that the value is nothing (even if no blank value was provided in the original criteria)
This isn't true, this also sets the value back to the first option of the originalselect
. And if there is a blank value, it doesn't require any mismatch setting anyway.
Both of these can be fixed by appending a blank option on init, but the following issue still exists:
- due to the
setValue
triggering a change on the originalselect
, the flexselect is still updated to match to either the blank value or text of an original blank value. (for example<option value=''>Select One...</option>
Proposed change
- on init, if
allowMismatch
orallowMismatchBlank
are true, append a blank option with an id/attribute for reference back to it. - add a mismatch parameter on
setValue
, which selects the option created above as opposed to the first blank value (due to issue 3) - on original
select
change, if the created blank option is selected, do not update val of flexselect
Unfortunately not the simplest of solutions, but it's the only way I can think of to have it working as expected in all cases.
I thought I'd get your opinion before going ahead and making these changes. Let me know what you think.