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 the user to add new items by simply writing them and hitting enter/comma #105

Open
wants to merge 10 commits into
from

Conversation

Projects
None yet
@theosp

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.

Show comment
Hide comment
@cburgmer

cburgmer Jun 14, 2011

Is this the same as #87 ?

Is this the same as #87 ?

@brodock

This comment has been minimized.

Show comment
Hide comment
@brodock

brodock Jun 20, 2011

+1 to get this merged

brodock commented Jun 20, 2011

+1 to get this merged

@vdepizzol

This comment has been minimized.

Show comment
Hide comment
@vdepizzol

vdepizzol 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.

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.

Show comment
Hide comment

raykin commented Jul 14, 2011

need it

@janpieper

This comment has been minimized.

Show comment
Hide comment
@janpieper

janpieper Aug 3, 2011

Contributor

+1

Contributor

janpieper commented Aug 3, 2011

+1

@twe4ked

This comment has been minimized.

Show comment
Hide comment

twe4ked commented Aug 7, 2011

+1

@loopj

This comment has been minimized.

Show comment
Hide comment
@loopj

loopj Aug 7, 2011

Owner

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?

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.

Show comment
Hide comment
@janpieper

janpieper Aug 8, 2011

Contributor

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

Contributor

janpieper commented Aug 8, 2011

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

@marijnvdwerf

This comment has been minimized.

Show comment
Hide comment
@marijnvdwerf

marijnvdwerf Aug 12, 2011

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

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.

Show comment
Hide comment
@ghost

ghost 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?

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.

Show comment
Hide comment
@marijnvdwerf

marijnvdwerf 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)

@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.

Show comment
Hide comment
@ghost

ghost 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.

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.

Show comment
Hide comment
@janpieper

janpieper Aug 19, 2011

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.

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.

Show comment
Hide comment
@Justinwceo

Justinwceo 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 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.

Show comment
Hide comment
@janpieper

janpieper Aug 24, 2011

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.

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.

Show comment
Hide comment
@Justinwceo

Justinwceo 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.

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.

Show comment
Hide comment
@speedmax

speedmax Sep 1, 2011

+1 merge plz

speedmax commented Sep 1, 2011

+1 merge plz

@mspasiuk

This comment has been minimized.

Show comment
Hide comment

mspasiuk commented Sep 6, 2011

+1 merge

@robink

This comment has been minimized.

Show comment
Hide comment
@robink

robink Sep 7, 2011

+1 merge

robink commented Sep 7, 2011

+1 merge

@mspasiuk

This comment has been minimized.

Show comment
Hide comment
@mspasiuk

mspasiuk Sep 8, 2011

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

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.

Show comment
Hide comment
@JohnGoodman

JohnGoodman Sep 8, 2011

This thread helped me out, thanks.

This thread helped me out, thanks.

@tankwanghow

This comment has been minimized.

Show comment
Hide comment

+1 merge

@wayx

This comment has been minimized.

Show comment
Hide comment
@wayx

wayx Oct 5, 2011

merge it please

wayx commented Oct 5, 2011

merge it please

@mean-cj

This comment has been minimized.

Show comment
Hide comment
@mean-cj

mean-cj Nov 13, 2011

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

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.

@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.

Show comment
Hide comment
@firulais

firulais Apr 12, 2012

merge, merge, merge

merge, merge, merge

@johans

This comment has been minimized.

Show comment
Hide comment
@johans

johans Jan 11, 2013

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

johans commented Jan 11, 2013

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

@janpieper

This comment has been minimized.

Show comment
Hide comment
@janpieper

janpieper Jan 11, 2013

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.

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.

Show comment
Hide comment
@dmitry

dmitry Jan 23, 2013

Why does it not merged?

dmitry commented Jan 23, 2013

Why does it not merged?

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