Open jiteshsojitra opened 7 years ago
The issue here is - as I can see it - If you have India and USA in the list of options, the actual values could be not "India" and "USA" but "91" and 1". So if you want to add "UK", how should the value "44" be known?
Just to clarify: I'm talking about the international call prefixes.
I'm sorry but in my example i'm talking about select values present in dropdown list. UK text is my custom if some user want to specify it in the input field. Right now the problem is, when you put focus outside immediately Chosen field clears that value. I'm expecting Chosen field keeps value as it is as a input field as well to re-use as custom entered value.
Sorry, but it seems I'm unable to understand the use case. Maybe someone else can or maybe you can explaine differently?
I understand the use case - it's like the tagging box in wordpress (among many others). Some call it "tagging", others "Dynamic Option Creation".
You are totally correct in saying that it makes no sense at all if your values are not (directly) related to the labels, and only a list of specific values are valid. This feature should definitely not be enabled by default.
But the new values are normally handled by some "external" system where you might specify the details of each tag separately. The "tag-box" just allows you to easily create new tags without leaving your current workflow - so in other words chosen would just insert a new option in the original select using the entered value for both the label and value and select that option. Then it would be up to the developer to handle this non-existent value upon form submission - to actually sanitize the value, add it to a database or whereever the values are coming from... if relevant at all - in some cases any entered value might be valid, and the purpose of chosen is just to provide easy access to a few common values.
Select2 has the feature: https://select2.org/tagging
I'm sorry, i'm saying something else; probably very easy to understand but we diverted communication to different feature. See this video - you will surely get it. Please re-read my issue to get more idea.
Repro steps video: https://www.screencast.com/t/gLFnxsnX
Even after seeing your screencast it still seems to me like you are referring to "dynamic option creation"... Have you looked at the select2 link at the end of my previous post and tried that?
Yes, Mikk; whatever link and information you provided completely makes sense. Thanks a lot!
I don't want to create the option, if it just preserves the value in dropdown list as input box then it also fine for me to use that custom value for other operation. At this point i like Chosen and don't want to switch to select2.
Need to play with java script a bit so it doesn't clear the value if it doesn't find from dropdown? Any help?
I'm not suggesting you switch to select2 - it was simply meant as an example.
As far as I know there is currently no way to do it with (a "vanilla") chosen, though the feature has been requested several times. I may have a go at it if I have time, but I won't make any promises just yet.
Have you looked at the coffeescript files to see if you might be able to do it yourself? Or if someone has already made a fork that supports it?
Agreed Mikk. The biggest problem with dynamic creation is:
I'm sorry i didn't take a look coffeescript files but i tried without any luck, as i'm new to all these stuff. Appreciated Mikk for your attention and it would be great if you put some kind of temporary solution without clearing input value when focus goes off and long term solution you can improve it professionally like Select2.
Agreed Mikk. The biggest problem with dynamic creation is:
* User may enter wrong and junk data and we can't save each and every values into DB (dropdown is picking up values from DB for professional software) * Dropdown will flood with unwanted values * Custom/floating input value is bother-less for admin if just used for other purpose and won't be saved
I'm sorry i didn't take a look coffeescript files but i tried without any luck, as i'm new to all these stuff. Appreciated Mikk for your attention and it would be great if you put some kind of temporary solution without clearing input value when focus goes off and long term solution you can improve it professionally like Select2.
I don't agree at all... Its the developers duty to check for these things. if you think like this you are making your modules less modular. You need to allow for freedom for the developer. At least allow for a disable option for the auto clear if no value is found. It doesn't even have to add to the list. If it can just stay in the text field then everything should be fine. The back-end developer can check for this and append the data to the database, when the page is reloaded the new value will appear in the select. I really don't get why you guys are saying these things... Where as if you "Hack" the select now and dynamically add the items to the options you will encounter these problems obviously but this will only be while the page is open or if you update the list via AJAX calls, exactly how you set it up now. So please re-conceder and just allow for "DON'T CLEAR THE FREAKEN LIST IF THERE ARE NO VALUES!"
I'm using Chosen and its great! More, i would like you to allow user to keep custom text if value not found from dropdown lists. This is one of the thing killing to specify custom/float value to use for other purpose.
My requirement is input value should preserve the text if value not found from dropdown lists.
Steps to reproduce
Assume dropdown value contains: India USA
Type UK
Move mouse outside dropwown
Actual: UK is removed because dropdown doesn't find it.
Expected: Preserve UK text as it is to use it for other purpose
I tried all the options mentioned in https://harvesthq.github.io/chosen/options.html but no luck. Any work around? JS customization help? Can you introduce such kind of new option? - Highly appreciated!