Skip to main content

How do I ajax query (select) on a huge number of records (zipcodes)?

Javascript • Asked by Brandon Buteaux

Gravatar
Brandon Buteaux (790 XP) on
Spaces-are-not-working-in-wysiwyg-editor-but-the-question-from-above.


Gravatar
Chris Oliver (169,620 XP) on
Hmm, spaces are working for me. Your post looks like you were in the code mode though.

You'll need an autocomplete or select library and then you'll need a JSON endpoint to gather the filtered records from. I did an episode on autocomplete here: https://gorails.com/episodes/global-autocomplete-search and I covered Selectize here: https://gorails.com/episodes/select-or-create-with-selectize-js

Selectize has an option for "remote data loading" as they call it. They have a couple demos at the bottom here that use Github and Rotten Tomatoes APIs. https://selectize.github.io/selectize.js/


Gravatar
Brandon Buteaux (790 XP) on
Spaces are working from my macbook on chrome and firefox.  However, on my windows 10 machine on the newest version of chrome spaces still are not working for some reason - that is just an fyi.

Thanks for your quick response and I realized the JS and endpoints - I also will go look at the selectize video of yours.  I did not know if there is a best practices or like they call it "Rails Way or Railsy" of doing it.  I come from C# and Python and those two languages are pretty explicit in ways to do things - I am trying to get used to Rails/Ruby and their being multiple proper ways to do things, haha.


Gravatar
Chris Oliver (169,620 XP) on
I'll have to boot into Windows and see if I can replicate that. What a weird problem. I'm also possibly going to swap out Trix editor anyways because it's not the best for syntax highlighting.

There isn't really a Rails way of doing things because Rails refuses to get too involved in the client side JS. I came from Python before I started Ruby and had the same sort of struggle. It's not common to have a whole bunch of options to tackle things in other communities!


Gravatar
Brandon Buteaux (790 XP) on
You are pretty awesome.  Thanks for the great work you do - and you are correct about other communities - i.e. "This is the WAY to do x, any other way is inefficient or incorrect" is pretty much what one gets most of the time.


Login or create an account to join the conversation.