mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
BUGFIX: Allow use on frontend
'Chosen' plugin assumed, but on front-end this is not a valid assumption.
This commit is contained in:
parent
fb049075d4
commit
850e5a51b7
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user