Skip to content

Use select2 for fancy select lists

Adam Becker edited this page Mar 26, 2015 · 2 revisions

use with FormRenderer 0.4.x

<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.1/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.1/js/select2.min.js"></script>
// Add select2
FormRenderer.Views.ResponseFieldDropdown = FormRenderer.Views.ResponseField.extend({
  field_type: 'dropdown',
  render: function(){
    FormRenderer.Views.ResponseField.prototype.render.apply(this, arguments);
    this.$el.find('select').select2({width: '100%'});
    return this;
  }
});