1. John Fuex
  2. ImprovedDropdown (jQuery Plugin)
  3. Issues
Issue #10 new

Customizable pattern matching logic (beginswith, contains,etc.)

Tárcio Zemel
created an issue

Currently, the plugin search for all matches of the term typed in the field. So, it finds "New York" if I typed "York". But in large lists (like 10k itens) the plugin slows down.

It would be great if the plugin had a option to choose what kind of filter is in action: if the "default" filter (current) or only search from point of the text being typed (eg. "York" only return "yorkshire").

Comments (10)

  1. John Fuex repo owner

    Good suggestion on the pattern matching logic.

    Side Note: 10K items is a pretty high number for a pre-loaded dropdown control. If you have that many I'd really suggest an AJAX auto-complete type control so you aren't loading the entire list on each page load. This is doubly true if you are concerned about performance, which it sounds like you are.

  2. Tárcio Zemel reporter

    Hi, John!

    Using AJAX, people without js enabled don't see the results. Besides, the site may have a huge traffic (my case, btw) and make many many requests to the DB it's not nice... To make the request once and cache it it's better!

    Thank you and I'm anxiously waiting for the improvements! \o/

  3. John Fuex repo owner

    Using a jQuery plugin like this one also isn't possible without js enabled. Your requirements would push me MORE towards an AJAX solution. Sending a list of 10K+ items to the client on a high volume website is suicide. You are optimizing in the wrong place.

  4. Tárcio Zemel reporter

    I think I don't expressed myself very well. Obviously without js enabled, jQuery and your plugin both don't work, but people still seeing a <select> and the web site still usable.

    To use a <select> in the content layer is more "progressive enhancement" than to use an autocomplete plugin, for instance. Luckily, your plugin is amazing and have support to more browsers than other similars, like chosen.

    When you implement the "matching logic" option, ImprovedDropdown will be the best jQuery plugin in this field! ;-)

  5. John Fuex repo owner

    That makes a lot more sense. Thanks for clarifying.

    BTW: If you need a solution ASAP, this should be fairly easy to manually hack into your version. The matching is controlled by the function function doesListItemMach(). Just tweak that line to use whatever pattern matching you prefer and it will likely work as you describe.

  6. Tárcio Zemel reporter

    Yeah, this is a kind of emergency thing... But I'm more a back-end guy, so I don't know what to change in your code.

    Maybe you can help me with this while the next version don't comes. I need a search like that example I showed before: typing "York" only retrieves "Yorkshire" (something like "York%").

    This modification is very complicated?

  7. John Fuex repo owner

    It would be trivial.

    Just find this function in the .js file and modify the conditional to match your needs. Any basic javascript tutorial will show you how to come up with a conditional that meets your needs.

    Function stringContainsCaseInsensitive(SearchIn, SearchFor) { return (SearchIn.toLowerCase().indexOf(SearchFor.toLowerCase())>-1); }

  8. Log in to comment