Allow users to add new items to a chosen select list #1029

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
4 participants

When the add_new_result_to_list flag is set to true, and when the search returns no results, the user can press enter to add the item they searched for.

Sweet! Is this paired with an event hook or callback argument that can be used to define additional processing (validation, persistence, feedback, etc)?

Thats a good idea, Ill put that in there sometime this weekend and ill email you when its there. is there any standard for a naming scheme for the event?

Nick

On Feb 9, 2013, at 10:19 AM, Scott Kroyer notifications@github.com wrote:

Sweet! Is this paired with an event hook or callback argument that can be used to define additional processing (validation, persistence, feedback, etc)?


Reply to this email directly or view it on GitHub..

You know, I'm not quite sure about naming standards yet either, but I just noticed another issue that seems to revolve around the same concept. Check out #166 if you want to check it out.

Collaborator

stof commented Feb 11, 2013

The Prototype version should be updated as well for contributions to be accepted. Both version should stay in sync feature-wise

There is a bug in this code. If you press "enter", and begin typing in a new character, the first character is swallowed. This happens only the first time around -- if you remove the item and add a new one back in, it won't occur.

Found another bug. New items are placed first instead of last.

nrschultz closed this Feb 15, 2013

I made two changes to your code to make the bugs go away. No idea if this is going to fix things for reals.

---> "this.form_field.add(new_option, this.form_field.options[this.form_field.options.length]);"
--> "return this.activate_field();" instead of .close_field().

This also needs a way to prevent new items from showing up in the dropdown list, or at least I think so.

Edit:

One more item, and I'm not sure if it is exclusive to this:

searchText = this.search_field.val() === this.default_text ? "" : $('

').text($.trim(this.search_field.val())).html();

BAD for this. "&" turns to "&" because of html().

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