I´m using chosen.js for Dropdowns in a form on a grails-environment. I want the users to be able to select an empty option, but somehow it is ignored. There must be a possibility to do this? Because the workaround to set an option like "select-none" and later in data-bindig make a if condition if select-none value= "" would be unpretty.
to show my problem :
for example this select :
<g:select id="foo" data-placeholder="bar" class="foo chzn-select" style="width: 245px;" tabindex="4"
from="${['M', ' ', 'F']}" value="foo" name="titel"/>
would return :
Sure this is a nice feature of chosen, but i guess my case is a common case and maybe someone of you already has a solution to override this behaviour
thanks in advance
You can also set *allow_single_deselect* to true. This will have a 'x' that allows user to deselect the option.
$(".chzn-select").chosen({ allow_single_deselect:true });
after some research i found this thread
https://github.com/harvesthq/chosen/issues/93
and my solution was prepending an option via JS before initialisation of chosen
$("#id").prepend("<option value='' > </option>");
So this one is Resolved, thanks to
and everyone who had a look at this
<g:select name="foo" from="${foos}" noSelection="[' ':' ']" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With