This repository has been archived by the owner. It is now read-only.

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

Open
wants to merge 10 commits into
base: master
from

Conversation

Projects
None yet
@theosp
Copy link

theosp commented May 17, 2011

No description provided.

gr2m and others added some commits Apr 29, 2011

You'll get errors if highlight_term is run with a term containing Reg…
…Exp special chars. So you better escape'em.


Cheers
Add a new function _add_token(id, name) that adds a token without the…
… need for an item

To DRY stuffs up, we now base the item based add_token() on _add_token()
Add a new option: newItemFilter
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

This comment has been minimized.

Copy link

cburgmer commented Jun 14, 2011

Is this the same as #87 ?

@brodock

This comment has been minimized.

Copy link

brodock commented Jun 20, 2011

+1 to get this merged

@vdepizzol

This comment has been minimized.

Copy link

vdepizzol commented Jun 21, 2011

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

This comment has been minimized.

Copy link

raykin commented Jul 14, 2011

need it

@janpieper

This comment has been minimized.

Copy link
Contributor

janpieper commented Aug 3, 2011

+1

1 similar comment
@twe4ked

This comment has been minimized.

Copy link

twe4ked commented Aug 7, 2011

+1

@loopj

This comment has been minimized.

Copy link
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

This comment has been minimized.

Copy link
Contributor

janpieper commented Aug 8, 2011

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

@marijnvdwerf

This comment has been minimized.

Copy link

marijnvdwerf commented Aug 12, 2011

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

@ghost

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

marijnvdwerf commented Aug 14, 2011

@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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

janpieper commented Aug 19, 2011

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

This comment has been minimized.

Copy link

Justinwceo commented Aug 24, 2011

@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

This comment has been minimized.

Copy link
Contributor

janpieper commented Aug 24, 2011

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

This comment has been minimized.

Copy link

Justinwceo commented Aug 24, 2011

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

This comment has been minimized.

Copy link

speedmax commented Sep 1, 2011

+1 merge plz

@mspasiuk

This comment has been minimized.

Copy link

mspasiuk commented Sep 6, 2011

+1 merge

1 similar comment
@robink

This comment has been minimized.

Copy link

robink commented Sep 7, 2011

+1 merge

@mspasiuk

This comment has been minimized.

Copy link

mspasiuk commented Sep 8, 2011

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

@JohnGoodman

This comment has been minimized.

Copy link

JohnGoodman commented Sep 8, 2011

This thread helped me out, thanks.

@tankwanghow

This comment has been minimized.

Copy link

tankwanghow commented Oct 5, 2011

+1 merge

@wayx

This comment has been minimized.

Copy link

wayx commented Oct 5, 2011

merge it please

@mean-cj

This comment has been minimized.

Copy link

mean-cj commented Nov 13, 2011

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

select_dropdown_item(this_li);
// Select the first item, unless we allow the user to add new
// items.
if (settings.allowNewItems === false) {

This comment has been minimized.

@joshholat

joshholat Jan 2, 2012

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

This comment has been minimized.

Copy link

firulais commented Apr 12, 2012

merge, merge, merge

@johans

This comment has been minimized.

Copy link

johans commented Jan 11, 2013

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

@janpieper

This comment has been minimized.

Copy link
Contributor

janpieper commented Jan 11, 2013

@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

This comment has been minimized.

Copy link

dmitry commented Jan 23, 2013

Why does it not merged?

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