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

Allow new item #16

Closed
allochi opened this issue Apr 4, 2012 · 4 comments
Closed

Allow new item #16

allochi opened this issue Apr 4, 2012 · 4 comments
Assignees
Milestone

Comments

@allochi
Copy link

allochi commented Apr 4, 2012

Hi,

Thanks for the new update, I was wondering if the functionality of allowing new item is going to be added in the future? in both select and multi-select.

Thanks!

@ivaynberg
Copy link
Contributor

hi, the functionality is already mostly implemented in this branch https://github.com/ivaynberg/select2/tree/sandbox/tagging via the createSearchOption function that can be specified in the options. please take a look and let me know if thats sufficient for your usecases. it should be merged soon.

@ivaynberg
Copy link
Contributor

this is now merged into master

@ghost ghost assigned ivaynberg Apr 10, 2012
@allochi
Copy link
Author

allochi commented Apr 10, 2012

Hi, I don't know why, but when I add the function createSearchChoice:

$(".select2-allowNew").select2({
   createSearchChoice: function(term){ return {id:term, text:term} }
});

the function get called, the new term show on the select text field, but when I call

$(".select2-allowNew").select2("val");

The new values are not returned in the array, am I doing something wrong? should createSearchChoice also include the logic of adding the new term into the values?

I'm reading the source code, trying figure it out :D

Can't thank you enough for all of that!

@allochi
Copy link
Author

allochi commented Apr 10, 2012

Never mind, stupid me :D

$("#e12").select2({tags:["red", "green", "blue"]});

You ROCK!

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

No branches or pull requests

2 participants