Ajax not filtering!?

812 views
Skip to first unread message

Mikko K

unread,
Aug 20, 2013, 12:45:54 PM8/20/13
to sel...@googlegroups.com
I want offline html5 app that has rarely-updating .json files (multiple of them)
and autocomplete from one of those.

I made it, but the select2 ajax has a problem:

it only underlines the match, not filter out the non matc.
Because support also for offline, i cannot supply php ?query=...  to the .json 
and for these i would not like to use the preload selection because then app will load slow (when loading those huges .json into javascript arrays)

SO:

A. 
How to apply a filter/match with js to ajax select2 ????


B.
I could do it, but cannot figure out a way to get the term-var into the  results: function (data) 


Samples:
(not working becaus i dont know how to add json into that)


snip.JPG

Igor Vaynberg

unread,
Aug 20, 2013, 12:54:10 PM8/20/13
to sel...@googlegroups.com
you can write your own query() function that on first query loads your dataset and then manually filters it to the keyword.

-igor


--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/groups/opt_out.

Mikko K

unread,
Aug 21, 2013, 6:10:42 AM8/21/13
to sel...@googlegroups.com
Thank you for your reply.
Is there a sample?
I did not find any working sample of ajax+json, not with local filtering.

My problem is that i cant get the variables to anywhere and no custom f-parameters work.
The query should also need the term and bunch of other variables.

m.c.r...@gmail.com

unread,
Jan 22, 2014, 10:29:47 PM1/22/14
to sel...@googlegroups.com
Hi Mikko,

I also have a problem with AJAX and the filtering not working. Did you end up finding a good query example or writing your own that solved the problem?

On Wednesday, 21 August 2013 20:10:42 UTC+10, Mikko K wrote:
> Thank you for your reply.Is there a sample?
Message has been deleted

koenva...@gmail.com

unread,
Jan 24, 2014, 6:57:28 AM1/24/14
to sel...@googlegroups.com, m.c.r...@gmail.com
I've been looking for this as well. I think I found a working example here: http://www.neilmeredith.com/codeprojectsamples/select2

The code used is here: http://www.codeproject.com/Articles/623566/Select2-The-Ultimate-jQuery-Autocomplete

koenva...@gmail.com

unread,
Jan 24, 2014, 7:20:36 AM1/24/14
to sel...@googlegroups.com, m.c.r...@gmail.com, koenva...@gmail.com

m.c.r...@gmail.com

unread,
Jan 24, 2014, 11:17:41 PM1/24/14
to sel...@googlegroups.com, m.c.r...@gmail.com, koenva...@gmail.com
Thank. I figured out I had to do it in my Rails controller for a Rails app. Here's an example:

q = params[:q]
table_var =TableName.arel_table
@table_instance_var = TableName.where(table_name[:attribute_name].matches("%#{q}%"))

Floras12

unread,
Jun 5, 2026, 5:38:42 AM (4 days ago) Jun 5
to select2
When organizing searchable lists or category based content, clear naming and structure make a big difference in how easily users can find what they need. The same idea applies to collections such as flowers that start with c, where consistent categorization improves navigation and overall usability. Small details in how data is grouped often have a bigger impact on user experience than expected.
Reply all
Reply to author
Forward
0 new messages