08 August 2014

Here is a tip about the select and forms.

We usually use some of plugin to prettify the select element and control or reflect the hidden select’s status with the elements plugin created like a mirror. ex. select2, fancyselect, …

When we reset the form, the select will back to its original status but the elements the plugin created would not. So we need to trigger select’s change event or destroy and init again to avoid the value is not consistent between the hidden select and elements plugin created.

resetForm = ->
  $('form')[0].reset()

Demo:

See the Pen nEtxj by Oliver - Frontend Developer (@Oliverl) on CodePen.