computing Archive

0

Tweaking Jquery AutoSuggest

I have been using the JQuery library for a long time now, and am still amazed at what people get it to do.  One feature that the base libaray was really lacking was a good Autosuggest for a text input.  It needed to be AJAX driven, and understand having multiple values.

I found a great example of what I wanted at Drew Wilson’s blog, complete with almost all the features I needed.

One thing his script is really lacking is a good way to show ALL the results.  We have a huge category list, and want to let someone browse them all.  In the base script, this isn’t going to work, since there isnt a way to make the look up fire off without input.  I didnt want my users to have to enter in, one by one, each letter of the alphabet looking for what they wanted, so I settled on using a double click event to force the display of the entire list.

And here is how to make that happen:

In the js file (jquery.autoSuggest.js) you will need to make some changes.

~line 149 add:

 }).dblclick(function(){
 if (timeout){ clearTimeout(timeout); }
 timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);

so it will look like:

 }).blur(function(){
 if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
 $(this).val(opts.startText);
 } else if(input_focus){
 $("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
 results_holder.hide();
 }
 }).dblclick(function(){
 if (timeout){ clearTimeout(timeout); }
 timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
 }).keydown(function(e) {

This will pull up a list on double click.  You can change dlbclick to just click for a single click response instead.

~line 226 comment out the lines:

if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){ return results_holder.hide(); }

and

if (string == prev) return;

and

if (string.length >= opts.minChars) {

and then on ~line 252 comment out

 } else {
 selections_holder.removeClass("loading");
 results_holder.hide();
 }

You will also want to turn the option “resultsHighlight” false, when you create the instance.

Now, on double click it will present a full list of options.

Enhanced by Zemanta
Share
0

New Look for this.rand()

Well, it has been a while since I did a new look for our homepage, so here it is.  What do ya think?  This is a theme instead of the usual totally custom method I do, but I like it.  It is a very magazine type of look, but it gets a lot more content on the front page, and uses the sidebars better.  So it should drive a little more traffic, and be easier to use for those that do show up.

Share
2

Reliving Childhood

Due to my recent injury and subsequent free time, I am VERY bored. I work a lot, just because of nothing else to do at 3a, but still, that gets old, especially since I don’t want to be a programmer/techie, I happen to love the team development aspects of management.

red_storm_rising_03

Well, as my team can attest, I have been pretty grouchy, mostly due to the snails pace at which my treatment is moving, but also the boredom. My father, did suggest to try and play a game he and I loved from back in the day of when computers had turbo buttons and DOS was the bomb. He was right (man that hurt to admit), and it was (is) a great game and a lot of fun. So, off I ran to download Red Storm Rising. Since it is an old DOS game, I also had to get a DOS Emulator called DOS Box. You can download both from this post, as I don’t think it is fair for you to have to jump through a bunch of stupid hoops on some of those download sites just to get it, so feel free to download them here instead. If you are also so inclined, it is a great book too.

Share