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

Enhancement - Added "create_on_enter" and "create_on_blur" plugins #1138

Closed
wants to merge 7 commits into from
Closed

Conversation

jhereu
Copy link

@jhereu jhereu commented Aug 16, 2016

Added two very simple plugins I needed at some point for multi selectizes to create an option with the text that was already typed without losing it. So, with those two plugins you can:

  • create_on_enter : Create option typing and pressing enter instead of tab or the delimiter character.
  • create_on_blur : Create option typing and clicking outside (blurring) the box without losing the input.

$element.selectize({ plugins: ['create_on_enter', 'create_on_blur'], maxItems: 2 });

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 7fd389a on JHereu:master into * on selectize:master*.

@jhereu
Copy link
Author

jhereu commented Oct 24, 2016

Full gist can be found here:
https://gist.github.com/JHereu/d012cc72ba285306fce669700649fc8d

@seltix5
Copy link

seltix5 commented Oct 4, 2018

Hello jhereu, I was searching for this functionality too to my select when I found your code, thanks!
But I dont understand why the "multi" mode only?
In my case I have a select to obviously select one of the options or just write a custom option.
I know I can just remove the if check and it works but I wanted to understand the reason?
Will it cause a problem elsewhere?
Thanks!

@jhereu
Copy link
Author

jhereu commented Oct 8, 2018

Hey @seltix5, glad you found it useful.

The multi mode check is defined because I coded it for some multiselector inputs. It didn't seem natural to me at the moment to write a new option inside a single selector and submit it pressing the enter key. In that case, I'd create a normal non-selector input.

I understand it can be useful for other people, so I will remove the if clause and commit it again. Unfortunately, this PR seems to have fallen into oblivion, though.

@seltix5
Copy link

seltix5 commented Oct 8, 2018

I hope the PR gets approved because when I first present this solution the first common mistake was to leave the selectize without confirming to add the new option, losing all the written text.
The solution for this was problem was this option. Thanks.

Removed If clauses checking if this.mode='multi' in create_on_enter and create_on_blur plugins
Changed author email of create_on_enter and create_on_blur
@jhereu
Copy link
Author

jhereu commented Oct 8, 2018

If clauses already removed in PR.

@jhereu jhereu changed the title Added "create_on_enter" and "create_on_blur" plugins Enhancement - Added "create_on_enter" and "create_on_blur" plugins Oct 8, 2018
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2021

This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

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

Successfully merging this pull request may close these issues.

None yet

3 participants