Skip to content
This repository was archived by the owner on Sep 10, 2023. It is now read-only.

Allow the user to add new items by simply writing them and hitting enter/comma#105

Open
theosp wants to merge 10 commits into
loopj:masterfrom
theosp:items-on-the-fly
Open

Allow the user to add new items by simply writing them and hitting enter/comma#105
theosp wants to merge 10 commits into
loopj:masterfrom
theosp:items-on-the-fly

Conversation

@theosp
Copy link
Copy Markdown

@theosp theosp commented May 17, 2011

No description provided.

gr2m and others added 10 commits April 29, 2011 07:12
…Exp special chars. So you better escape'em.


Cheers
… need for an item

To DRY stuffs up, we now base the item based add_token() on _add_token()
If newItemFilter is a function we call it with a callback named "addItem" and the value of the item
the user wants to add.

After manipulating the item, calling addItem(item) will add it.
You can choose not to add an item by simply not calling addItem.
@cburgmer
Copy link
Copy Markdown

Is this the same as #87 ?

@brodock
Copy link
Copy Markdown

brodock commented Jun 20, 2011

+1 to get this merged

@vdepizzol
Copy link
Copy Markdown

Hey @brodock. I recommend you to take a look at my fork of jquery-tokeninput at https://github.com/vdepizzol/jquery-tokeninput. It implements this and a couple of other things as well.

@raykin
Copy link
Copy Markdown

raykin commented Jul 14, 2011

need it

@janpieper
Copy link
Copy Markdown
Contributor

+1

1 similar comment
@twe4ked
Copy link
Copy Markdown

twe4ked commented Aug 7, 2011

+1

@loopj
Copy link
Copy Markdown
Owner

loopj commented Aug 7, 2011

Hey guys, I've merged in some changes recently which make this pull request difficult to merge.

Anyone interested in refactoring this pull request to work with 1.6.0 and the new tokenValue setting?

@janpieper
Copy link
Copy Markdown
Contributor

I really need this feature, so i'll do this refactoring.

@marijnvdwerf
Copy link
Copy Markdown

I've already updated it about two weeks ago, maybe it's of some help?
https://github.com/navale/jquery-tokeninput

@ghost
Copy link
Copy Markdown

ghost commented Aug 13, 2011

navale, i tried your fork (master and token-on-the-fly branch) but couldn't get this feature working out of the box.
Do I need a certain config parameter?

@marijnvdwerf
Copy link
Copy Markdown

@Capsized: Like on this pull request's diff page; allowNewItems is false by default, so you need to set it to true in your config :)

Op 14 aug. 2011 om 00:57 heeft capsizedreply@reply.github.com het volgende geschreven:

navale, i tried your fork (master and token-on-the-fly branch) but couldn't get this feature working out of the box.
Do I need a certain config parameter?

Reply to this email directly or view it on GitHub:
#105 (comment)

@ghost
Copy link
Copy Markdown

ghost commented Aug 14, 2011

@navale, thanks for pointing that out. :) still learning to find my way around github.
And works like a charm, just what I needed.

@janpieper
Copy link
Copy Markdown
Contributor

Can someone please review and test my changes?

Changes to master:
https://github.com/janpieper/jquery-tokeninput/commit/e0db55be562976339a03ef89df4bab22ed509055

Changes to gh-pages:
https://github.com/janpieper/jquery-tokeninput/commit/abee08bf8d72dc37187c3da555bf35456adbb30e

The demo page won't work without changing the script path for jquery-tokeninput.js.

@Justinwceo
Copy link
Copy Markdown

@janpieper I tried using your changes for the allowNewTokens and the token-field changes back to a regular text-field when i add that new option. If I use the regular options it works correctly.

This doesn't work:

$(function() {
$("#business_token").tokenInput("/businesses.json", {
prePopulate: $("#business_token").data("pre"),
tokenLimit:1,
preventDuplicates: true,
allowNewTokens: true,
searchingText: "Looking for business...",
});
});

This DOES work:

$(function() {
$("#business_token").tokenInput("/businesses.json", {
prePopulate: $("#business_token").data("pre"),
tokenLimit:1,
preventDuplicates: true,
searchingText: "Looking for business...",
});
});

Even when I removed all other options besides allowNewTokens, it still didn't work.

@janpieper
Copy link
Copy Markdown
Contributor

It's not possible to use allowNewTokens: true with tokenValue: "id" (default) because new items does not have an id. You need to change tokenValue to e.g. name.

@Justinwceo
Copy link
Copy Markdown

Well....it does "work" when added tokenValue: "name" but in my Ruby-on-Rails application it should also have an ID assigned to it along with a name when I create it. Without RoR I can say it does work. Thanks, good job.

@speedmax
Copy link
Copy Markdown

speedmax commented Sep 1, 2011

+1 merge plz

@mspasiuk
Copy link
Copy Markdown

mspasiuk commented Sep 6, 2011

+1 merge

1 similar comment
@robink
Copy link
Copy Markdown

robink commented Sep 7, 2011

+1 merge

@mspasiuk
Copy link
Copy Markdown

mspasiuk commented Sep 8, 2011

I opened an issue, maybe could be related to this new feature, see #179

@JohnGoodman
Copy link
Copy Markdown

This thread helped me out, thanks.

@tankwanghow
Copy link
Copy Markdown

+1 merge

@wayx
Copy link
Copy Markdown

wayx commented Oct 5, 2011

merge it please

@mean-cj
Copy link
Copy Markdown

mean-cj commented Nov 13, 2011

Allow the user to add new items :)
mean-cj@ecb8b04

Comment thread src/jquery.tokeninput.js
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you check for this here and then not allow selection? Doing so breaks the ability to use the arrows to search through results.

@firulais
Copy link
Copy Markdown

merge, merge, merge

@johans
Copy link
Copy Markdown

johans commented Jan 11, 2013

@janpieper Do you still have your refactoring? The links are broken...

@janpieper
Copy link
Copy Markdown
Contributor

@johans yeah i still have a local copy (see https://gist.github.com/4512379), but it hasn't been updated since I made my changes, so if you need some 1.6.1 features, you need to merge them by yourself. Will try to setup a new fork over the weekend.

This code example isn't tested and is poorly extracted from my application that is using this jQuery-plugin.

$("#my-fancy-token-input").tokenInput("/autocomplete", {
  allowNewTokens: true,
  propertyToSearch: "label",
  tokenValue: "label",
  preventDuplicates: true
});

If you have any problems getting it working, please contact me and i'll help you.

@dmitry
Copy link
Copy Markdown

dmitry commented Jan 23, 2013

Why does it not merged?

@loopj loopj force-pushed the master branch 2 times, most recently from fd2316b to 8a8390e Compare August 3, 2023 06:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.