Reuse token field mirror (prevent multiple unclean fields in dom).
This commit is contained in:
parent
6c7d9bcb4d
commit
e0e4fa249c
1 changed files with 7 additions and 2 deletions
|
@ -135,7 +135,7 @@
|
|||
}
|
||||
|
||||
// Set up mirror for input auto-sizing
|
||||
this.$mirror = $('<span style="position:absolute; top:-999px; left:0; white-space:pre;"/>');
|
||||
this.$mirror = $('<span class="js-tokenfieldMirror" style="position:absolute; top:-999px; left:0; white-space:pre;"/>');
|
||||
this.$input.css('min-width', this.options.minWidth + 'px')
|
||||
$.each([
|
||||
'fontFamily',
|
||||
|
@ -149,7 +149,12 @@
|
|||
], function (i, val) {
|
||||
_self.$mirror[0].style[val] = _self.$input.css(val);
|
||||
});
|
||||
if (!$('.js-tokenfieldMirror').get(0)) {
|
||||
this.$mirror.appendTo( 'body' )
|
||||
}
|
||||
else {
|
||||
this.$mirror = $('.js-tokenfieldMirror')
|
||||
}
|
||||
|
||||
// Insert tokenfield to HTML
|
||||
this.$wrapper.insertBefore( this.$element )
|
||||
|
|
Loading…
Reference in a new issue