This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Define $element.data('bs.tokenfield') earlier. #150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Define
$element.data('bs.tokenfield')
at the beginning ofTokenfield()
instead of after initialization so the Tokenfield object is also available through$(this).data('bs.tokenfield')
in events triggered during initialization. This is useful whentokenfield:createtoken
ortokenfield:createdtoken
events have been attached before initialization, so they are run on page load if the tokenfield input has a default value on page load.Before this fix you would get an error if you tried to use
$(this).data('bs.tokenfield').$input
inside atokenfield:createtoken
event that was bound before tokenfield initialization like thisYou could just bind the event after
.tokenfield()
but then the create event would not be run on initialization (on page load) when tokens are created from the default value attribute of the#tokenfield
input.Before this fix you could use a workaround of recreating the tokens after initialization to fire the create events like so
$('#tokenfield').tokenfield('setTokens', $('#tokenfield').tokenfield('getTokens'));
but this is not needed anymore after this commit.