Added support for select2 control for using select2 instead of simple

select input.
This commit is contained in:
Ashesh Vashi 2016-01-09 18:08:44 +05:30
parent d2897a334f
commit 8f733aabd0

View File

@ -1274,5 +1274,21 @@
return groups;
};
/*
* Backform Select2 control.
*/
var Select2Control = Backform.Select2Control = Backform.SelectControl.extend({
render: function() {
Backform.SelectControl.prototype.render.apply(this, arguments);
var col = _.defaults(this.field.toJSON(), this.defaults)
/*
* Add empty option as Select2 requires any empty '<option><option>' for
* some of its functionality to work and initialize select2 control.
*/
this.$el.find("select").prepend($('<option></option>')).select2(col.select2);
return this;
}
});
return Backform;
}));