This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Define $element.data('bs.tokenfield') earlier.#150
Open
Haprog wants to merge 1 commit intosliptree:masterfrom
Open
Define $element.data('bs.tokenfield') earlier.#150Haprog wants to merge 1 commit intosliptree:masterfrom
Haprog wants to merge 1 commit intosliptree:masterfrom
Conversation
Define bs.tokenfield at the beginning of Tokenfield() instead of after initialization so the Tokenfield object is also available through $(this).data('bs.tokenfield') in events triggered during initialization. This is useful when createtoken or 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.
Contributor
Author
|
This fixes issue #151 |
Contributor
Author
|
Someone might want to write a test case to ensure that this doesn't break later. I don't yet have experience on writing tests in a JS environment. |
Contributor
Author
|
I was also wondering should I run |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:createtokenortokenfield:createdtokenevents 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').$inputinside atokenfield:createtokenevent 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#tokenfieldinput.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.