Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions js/bootstrap-tokenfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
.css(hidingPosition, '-10000px')
.prop('tabindex', -1)

// Update tokens on form reset
this.$element.closest('form').on('reset', function (e) {
// Set a timeout to run code after the reset event is finished
window.setTimeout(function(){
var newValue = _self.$element.val();
// Convert empty string to empty array because setTokens() ignores falsy values (like empty string)
newValue = ( newValue === '' ? [] : newValue );
_self.setTokens(newValue, false, false)
}, 0);
})

// Create a wrapper
this.$wrapper = $('<div class="tokenfield form-control" />')
if (this.$element.hasClass('input-lg')) this.$wrapper.addClass('input-lg')
Expand Down