Skip to content
This repository has been archived by the owner on Feb 18, 2018. It is now read-only.

Which callback filters before adding? #29

Open
mimhof1 opened this issue Oct 18, 2013 · 5 comments
Open

Which callback filters before adding? #29

mimhof1 opened this issue Oct 18, 2013 · 5 comments

Comments

@mimhof1
Copy link

mimhof1 commented Oct 18, 2013

Greetings, I'm trying to locate the correct callback to filter a selection before allowing it to be added to the list. The basic idea is if the entered || comma-ed || tabbed || query is not a valid email ( using a regex here) then it clears the input box and prevents the add. I am about to hack beforeRequest but it seems to be fired with every keypress instead of hooking right before adding.

@knalli
Copy link
Member

knalli commented Oct 18, 2013

Hi,

that is not available currently. Min chars, max chars and double entries are prevented, but nothing further than that.

If you mean, please make a PR. It's welcome.

Have a look https://github.com/hlsolutions/jquery-autosuggest/blob/c7c9c93c800ee6449cea38d798ea64a8878fef98/src/jquery.autoSuggest.coffee#L983-998

@mimhof1
Copy link
Author

mimhof1 commented Oct 18, 2013

Hi Jan...I'm going to go after it then using beforeRequest in the
meantime. Would you suggest that to be the best entry point? WHat I'll do
is take the query and check if tab, enter, or comma was the last key, then
if so, run the regex filter and if pass, return query and if not, clear and
return empty. Sound feasible?

On Fri, Oct 18, 2013 at 3:25 PM, Jan Philipp [email protected]:

Hi,

that is not available currently. Min chars, max chars and double entries
are prevented, but nothing further than that.

If you mean, please make a PR. It's welcome.

Have a look
https://github.com/hlsolutions/jquery-autosuggest/blob/c7c9c93c800ee6449cea38d798ea64a8878fef98/src/jquery.autoSuggest.coffee#L983-998


Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-26622901
.

@mimhof1
Copy link
Author

mimhof1 commented Oct 18, 2013

FYI, not sure if I sent that PR to the right place.

On Fri, Oct 18, 2013 at 3:55 PM, marc imhof [email protected] wrote:

Hi Jan...I'm going to go after it then using beforeRequest in the
meantime. Would you suggest that to be the best entry point? WHat I'll do
is take the query and check if tab, enter, or comma was the last key, then
if so, run the regex filter and if pass, return query and if not, clear and
return empty. Sound feasible?

On Fri, Oct 18, 2013 at 3:25 PM, Jan Philipp [email protected]:

Hi,

that is not available currently. Min chars, max chars and double entries
are prevented, but nothing further than that.

If you mean, please make a PR. It's welcome.

Have a look
https://github.com/hlsolutions/jquery-autosuggest/blob/c7c9c93c800ee6449cea38d798ea64a8878fef98/src/jquery.autoSuggest.coffee#L983-998


Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-26622901
.

@knalli
Copy link
Member

knalli commented Oct 18, 2013

Hm. I don't think so.

  1. Clone/Checkout this repository (hlsolutions/hquery-autosuggets)
  2. Make a branch
  3. Put all your commits into this and make a PR by visiting this page https://github.com/hlsolutions/jquery-autosuggest/pulls

@mimhof1
Copy link
Author

mimhof1 commented Oct 19, 2013

Hi Jan, I was able to create a workaround using the callback
afterSelectionAdd instead of beforeRequest.
Basically, it takes "item", check that key I want to filter( item.email),
and if it fails, forces an immediate
$("input[name="test).autoSuggest('remove',item.email);
Essentially, the item got added to the list, then we checked it, and
because it failed, turned around and removed it. It's fast enough for what
we need to do because the data in the list isn't being used until a
separate function is called elsewhere. Thanks again for taking this plugin
to a new level...and thanks for the quick responses. BTW I found your
version after chasing down issues in the first one and saw your link to
yours. Thanks for taking the time to do that.

On Fri, Oct 18, 2013 at 6:52 PM, Jan Philipp [email protected]:

Hm. I don't think so.

  1. Clone/Checkout this repository (hlsolutions/hquery-autosuggets)
  2. Make a branch
  3. Put all your commits into this and make a PR by visiting this page
    https://github.com/hlsolutions/jquery-autosuggest/pulls


Reply to this email directly or view it on GitHubhttps://github.com//issues/29#issuecomment-26635807
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants