Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Suggestion] Allow configuration via data- attributes #18

Open
caffeinatedMike opened this issue Aug 5, 2022 · 0 comments
Open

Comments

@caffeinatedMike
Copy link

Currently, when needing to create tagsinputs with any options we need to destroy/re-create the tagsinput elements that are created when select tags contain the data-role=tagsinput data attribute. To avoid this, plus to add a very useful way to create tailored tagsinputs without needing any javascript (just the data-role=tagsinput data attribute), I'd like to suggest an improvement that would allow settings most of the settings via data attributes.

This has been done on various packages for convenience sake.
Example: bootstrap-datetimepicker

My thinking is to use the same standard camelCase-to-hyphenated approach:

Option data- Attribute Equivalent
tagClass data-tag-class
tagClass data-tag-class
itemValue data-item-value
itemText data-item-text
maxTags data-max-tags 1
confirmKeys data-confirm-keys 2
maxChars data-max-chars 1
trimValue data-trim-value 3
allowDuplicates data-allow-duplicates 3
focusClass data-focus-class
freeInput data-free-input 3
cancelConfirmKeysOnEmpty data-cancel-confirm-keys-on-empty 3

1: These would need to be cast to numbers
2: The value would need to be a comma-separated list, which would be split to create the array.
3: There are multiple ways to handle booleans, but the easiest is to just do string comparison against "true"/"false".

The only two options that would be omitted are typeahead and onTagExists, unless someone can think of a way to incorporate those.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant