0

I have a form that uses chosenjs for the multiselects. I added garlicjs to persist the data but I'm not if I can get the chosenjs choices to persist.

here is the fiddle. https://jsfiddle.net/dzyggftn/2139/

if you add a few items in the multiselect and enter a values in the text fields, tab through them but do not hit submit, then refresh the page. the text fields are persisted but the chosenjs choices are not.

<form data-persist="garlic" method="POST">

<div>
<select data-placeholder="Choose a Country..." class="chosen-select" multiple style="width:350px;" tabindex="4">
            <option value=""></option>
            <option value="Any">[Any]</option>
            <option value="United States">United States</option>
            <option value="United Kingdom">United Kingdom</option>
            <option value="Afghanistan">Afghanistan</option>
            <option value="Aland Islands">Aland Islands</option>
            <option value="Albania">Albania</option>
            <option value="Algeria">Algeria</option>
            <option value="American Samoa">American Samoa</option>

          </select>    
</div>
<div>
input one<input type="text" name="one"/>
</div>
<div>
input two<input type="text" name="two" />
</div>
<div>
input three<input type="text" name="three" />
</div>
<input type="submit"/>

  </form>  
Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79

1 Answers1

1

Add a call to the garlic plugin for the chosen field on document ready.

https://jsfiddle.net/dzyggftn/2141/

$(function() {
    $('.chosen-select').garlic();
})
kadeer
  • 151
  • 1
  • 9