I have a form with a multiple select field, created using Formtastic and Chosen.
This form has a multiple select field, here is the rails code for it:
= semantic_form_for 'post', :url => action_name_post_path(@post), :html => {:method => :put}, :remote => true do |f|
= f.input :blogs, :label => _("Blog"), :as => :select, :multiple => :true, :input_html => {:class => "chzn-select"}, :collection => Blog.all
I would like to reset the input field using jQuery (the form is submitted and reset remotely), and I can't seem to figure out how to remove the selected elements//clear the input field. The issue is that chosen changes the input field so it isn't a simple text area.
Can anyone point me in the right direction?
Seems like combination of the two answers works for me:
$('.chosen-select option').prop('selected', false).trigger('chosen:updated');
This deselects all options and also resets the chosen drop down.
http://jsfiddle.net/donkeysauras/j9yuL/ <-- working example
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