Merge pull request #27 from lingo/newmaster

BUGFIX: Allow use on frontend
This commit is contained in:
Christopher Pitt 2015-08-21 13:16:28 +12:00
commit 128f06a692

View File

@ -9,22 +9,28 @@
* we'll see an extra field where there should be only one.
*/
$.fn.chosenDestroy = function () {
$(this)
.show() // The field needs to be visible so Select2 evaluates the width correctly.
.removeClass('chzn-done')
.removeClass('has-chzn')
.next()
.remove();
return $(this);
var $this = $(this);
if ($this.siblings('.chzn-container').length) {
$this
.show() // The field needs to be visible so Select2 evaluates the width correctly.
.removeClass('chzn-done')
.removeClass('has-chzn')
.next()
.remove();
}
return $this;
};
$.entwine('ss', function ($) {
$('.ss-tag-field + .chzn-container').entwine({
$('.ss-tag-field.has-chzn + .chzn-container, .ss-tag-field:not(.has-chzn)').entwine({
applySelect2: function () {
var self = this,
$select = $(this).prev();
$select = $(this);
if ($select.prev().hasClass('ss-tag-field')) {
$select = $select.prev();
}
// There is a race condition where Select2 might not
// be bound to jQuery yet. So here we make sure Select2