views:

6509

answers:

5

Hi all,

I was looking for a jquery plugin that'll filter a table according to input values. I came across http://rikrikrik.com/jquery/quicksearch/, but i can't figure out how to make it work for an already existing input box. Currently it create a new input form for me (which i don't want) but i'd like to be able to use it with an existing input box that has a input submit button.

Thanks in advance

+1  A: 

This is not possible with this plug-in out-of-the-box, unless you dig into its code and modify it to do this.

The search inputbox is automatically generated by its own javascript and there are no options to change that behavior.

ichiban
This was probably true back when @ichiban wrote it, but it's not any more; see my answer.
Craig Walker
A: 

I tried to make a link insert a new value into the input generated by the plugin, which works (it inserts the new value to the input) - but it won't fire the search unless I continue typing.

Maybe there's a way to fake a keypress or something like that to fire the search/filtering?

A: 

@Adam, try firing the onKeyUp of the plugin-generated text field. First, you need to know the id of that field (use firebug), let's say it's generated_fld, then the code will be:

$(document).ready(function() {
   $("#my_other_input").keyup(function(){
       $("#generated_fld").val($(this).val()).keyup();
   })
});
Makram Saleh
A: 

It looks like time has answered your question for you. QuickSearch does in fact allow you to attach the search function to a preexisting text input box.

riklomas mentions that:

Note that the usage has changed in the latest version of quicksearch, the code is not backwards compatible, the form and input are not build by the script any more.

I've just started using it today and it looks like it works pretty well. It does appear to eat up it's share of CPU, at least on my testing environment (Firefox 3.6, OS X, and a pretty large data set), but that's probably not unique to this particular plugin.

Craig Walker