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 duplicate values in an input #129

Open
jbrooksuk opened this issue Sep 24, 2013 · 51 comments
Open

Allow duplicate values in an input #129

jbrooksuk opened this issue Sep 24, 2013 · 51 comments
Labels
consensus on need enhancement pending review This issue was closed as stale; since then additional review has been requested. pull request welcome
Milestone

Comments

@jbrooksuk
Copy link
Contributor

Is it possible to have an input element which allows duplicate values? The reason is, I'm trying to build a form which allows people to enter ages of children, which can of course, be the same; twins, triplets etc.

@flamber
Copy link

flamber commented Sep 25, 2013

Version 0.8 will allow this - if I understand your issue correctly - have a look at issue #76

@jbrooksuk
Copy link
Contributor Author

Not quite.

Say I have an input element with the values 1-17. I need to be able to select any number in that range multiple times. So after I've finished picking my values, I could end up with 1, 1, 3, 5 as the output.

@jbrooksuk
Copy link
Contributor Author

Any news on this?

@FoboCasteR
Copy link

Try last version.

@jbrooksuk
Copy link
Contributor Author

@FoboCasteR am I needing to use any new settings? It's not working by default.

@FoboCasteR
Copy link

#76 - Here I used standalone version. Works fine with default settings.

@jbrooksuk
Copy link
Contributor Author

No. This wasn't what I meant.

My problem doesn't involve optgroups. I just need to be able to select the same value more than once.

@ohaibbq
Copy link

ohaibbq commented Nov 20, 2013

+1

@jbrooksuk did you ever find a solution to this?

@jbrooksuk
Copy link
Contributor Author

@ohaibbq, I'm afraid I never did.

@airwin
Copy link

airwin commented Nov 27, 2013

i think this issue may need to have some modification to the selectize.js file

steps(with selectize v0.8.5):

1:make the selected items can be duplicate when “create”
line:2494
CHANGE: addItem: function(value) {
TO: addItem: function(value, is_create) {

line:2502
CHANGE: if (self.items.indexOf(value) !== -1) {
TO: if (!(is_create && self.settings.enableCreateDuplicate) && self.items.indexOf(value) !== -1) {

note here i add a new option in settings named “enableCreateDuplicate” to switch this feature

2:sign as an user-create item in the createItem function
line:2625
CHANGE: self.addItem(value);
TO: self.addItem(value, true); // sign as an user-create item

3:add the new options where init selectize
$(select).selectize({enableCreateDuplicate: true});

now it should can accept duplicate values when create.
try it. :)

@Inateno
Copy link

Inateno commented Dec 18, 2013

EDITED (my bad coding the night huehue) so.

So, I got the same problem than @jbrooksuk and solved it.
You were right @airwin but this work only when you create an entry it's not perfect to work like I wanted (and I think like he wanted) and I didn't have what you are saying at the same line... :/ with the 0.8.5.

Just to be sure we are speaking about the same thing this code is to made possible to add the same searched value (so duplicated). I think some people here didn't understood @jbrooksuk request.
Little example, if you have [ "hello", "banana", "potatoes" ] as possible results, we wanted to be able to select 2 or 3 times hello, so our result could be [ "hello", "hello", "banana", "hello" ].

Hope is that you were looking for, I didn't wrote all of this for nothing xD

So code (I'll give my lines, but maybe it's different, don't care, just search the same thing).
We don't need the "is_create" bool because we want to allow duplicate entry on search and on create.

LINE 1686 in the addItem function scope replace the if(self.items.indexOf(value) !== -1) by
if ( !self.settings.enableDuplicate && self.items.indexOf(value) !== -1 )
This will allow to push a value that already exist ine your values

Now, after a long search inside the code (ok I just see it in the doc/usage, but looked before xD), there is an option to let the values already used.
set hideSelected: false when init your selectized item.

With this option and the new enableDuplicate, you will see them in the list, and will be able to add them again.

Done that's all.
I want to "stack" duplicatas in the same result by adding a xN prefix, I'll see how to do this ^^

Maybe pushing it in the next release ? It's not heavy and very usefull in my opinion.

@jbrooksuk
Copy link
Contributor Author

@Inateno that's exactly what I want.

@airwin
Copy link

airwin commented Dec 18, 2013

@Inateno nice solution~!

@xdbr
Copy link

xdbr commented Jan 6, 2014

Same use case here as @jbrooksuk ( @jbrooksuk: did you get the hacks outlined above to work for you?).

Judging by looking at the code as of 0.8.5 I can see changes that hint me towards there being an option inputMode: multi/single. However this is not mentioned in the documentation (usage.md).

Now I am confused whether this is already resolved and this issue to be closed as of 0.8.5 or not? How would I have to go about multiple values, as in @Inateno's example?

@airwin
Copy link

airwin commented Jan 7, 2014

@xdbr there‘s not an official solution yet, u can use @Inateno 's code above.

@xdbr
Copy link

xdbr commented Jan 8, 2014

@airwin: thanks, of course @Inateno's solution works nicely, my very stupid bad...

@xdbr
Copy link

xdbr commented Jan 8, 2014

As a heads up: I forked and tried to integrate the solution outlined above to be able to offer a pull request. However, the grunt builds don't work, because of #232 which itself is blocked by this

@jbrooksuk
Copy link
Contributor Author

@brianreavis have you had any thoughts about this?

jbrooksuk added a commit to BlueBayTravel/selectize.js that referenced this issue Mar 10, 2014
@jbrooksuk
Copy link
Contributor Author

I've made a PR that fixes this.

@msangel
Copy link

msangel commented Sep 17, 2014

will it be merged in master branch?

@jmav
Copy link

jmav commented Oct 29, 2014

What's the status about that?

@Anxy
Copy link

Anxy commented Oct 30, 2014

Use this version: https://github.com/BlueBayTravel/selectize.js

It works like a charm, in option give Boolean for: duplicates: true/false

Hope this helps!

From: Jure [mailto:notifications@github.com]
Sent: Wednesday, 29 October 2014 11:32 PM
To: brianreavis/selectize.js
Cc: Anxy
Subject: Re: [selectize.js] Allow duplicate values in an input (#129)

What's the status about that?


Reply to this email directly or view it on GitHub #129 (comment) . https://github.com/notifications/beacon/AH1BxSC0nbe2N_zsgjzMSRr80a6qSoiEks5nISMdgaJpZM4BB7xD.gif

@jbrooksuk
Copy link
Contributor Author

@Anxy you'll need to use the right branch; https://github.com/BlueBayTravel/selectize.js/tree/allow-duplicates

@thehonestcto
Copy link

Ah, we really need this feature too. It looks like a small fix. Why isn't added in the main release? It's very useful!
Thank you in advance!
And...by the way, great piece of software. ;)

@ben-pr-p
Copy link

Is there any other library that allows this?

@krassowski
Copy link

+1 for this functionality. This is really desired enhancement.

@vtni
Copy link

vtni commented Mar 5, 2017

I would be interested in this functionality, too (and using the "official" version)

@mmizera
Copy link

mmizera commented Jun 22, 2017

Same here, this really should be included.

@joshhornby
Copy link

Since the above branch has been removed, is there a current solution for this?

@Pictor13
Copy link
Contributor

Why has the branch been removed?

@konradb90
Copy link

@feliperaul
Copy link

In my countries.sql, I have 246 countries but only 227 international phone code numbers. This means I can't use selectize for choosing country codes.

oyejorge added a commit to orchidjs/tom-select that referenced this issue Sep 18, 2020
@risadams
Copy link
Contributor

risadams commented Dec 1, 2020

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

@risadams risadams closed this as completed Dec 1, 2020
@thehonestcto
Copy link

Sorry, but why is this closed? Such a long discussion with including samples, proposed fixes and so on. What's the reason of closing it without actually doing it?

@risadams
Copy link
Contributor

risadams commented Dec 1, 2020

Sorry, but why is this closed?

With the project being unmaintained for such a long time, our current focus is regaining a fair baseline and assessing items based on activity. The only fair way of doing this is by bulk closing items without any major activity and re-opening on request.

(side note, this shouldn't have been caught in that filter; sorry)

@risadams risadams reopened this Dec 1, 2020
@risadams risadams added the pending review This issue was closed as stale; since then additional review has been requested. label Dec 1, 2020
@github-actions
Copy link
Contributor

This issue 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

@Mtmaciel
Copy link

This issue still need a fix

@RefSocAnalytics
Copy link

It would be great to have the duplicate values capacity added or resolved. Great software, thank you!

@sayajin101
Copy link

+1

@fknorn
Copy link

fknorn commented Mar 28, 2021

+1 here too, thanks

@ymeric
Copy link

ymeric commented Jun 10, 2021

The solution links provided are broken, and proposed code changes are not working for me. I had worked on this issue before and come out with attached solution based on latest code base (v0.12.6). The change introduces a new setting: allowDuplicateSelection.
selectize.js.zip
.

@Sapper-Morton
Copy link

This issue is still unresolved in 0.14.0.

@simonf-dev
Copy link

+1 here too, thanks

@abdullzz
Copy link

abandoned +1

@tholn
Copy link

tholn commented Nov 1, 2023

The solution links provided are broken, and proposed code changes are not working for me. I had worked on this issue before and come out with attached solution based on latest code base (v0.12.6). The change introduces a new setting: allowDuplicateSelection. selectize.js.zip .

@ymeric Please help me. when deleting is deleting all duplicate values. Desired: delete only specified value

@ddofborg
Copy link

LINE 1686 in the addItem function scope replace the if(self.items.indexOf(value) !== -1) by if ( !self.settings.enableDuplicate && self.items.indexOf(value) !== -1 ) This will allow to push a value that already exist ine your values

I updated the code in v0.15.2 and the values are indeed added to the list. But the textfield still only contains unique items, duplicates are non rendered. Anyone solved this yet?

@TearsRfuel
Copy link

please fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus on need enhancement pending review This issue was closed as stale; since then additional review has been requested. pull request welcome
Projects
None yet
Development

No branches or pull requests