Other Entries

Log

Safari 2.0.3 and script.aculo.us’s Ajax.Autocompleter

Safari 2.0.3 breaks functionality that is essential to the use of script.aculo.us’s Ajax.Autocompleter class. When selecting an item from the generated list by pressing Return, the form is submitted.

I’ve searched far and wide for a fix for this and can’t seem to find one that works reliably for form submission. So here’s an ugly hack. Let’s say your autocompleting text field has an id auto_complete.

$ ('auto_complete').onkeypress = killIt;

function killIt (e)
  {
  if (typeof e != 'undefined' && e.keyCode == 13)
    {
    return false;
    }
  return true;
  }

And that’s that.

04/05/06 11:46AM Ajax

Comments

Rebecca Younes:

Thanks for this solution. However, the code generates an error in IE6 because the keypress event is not defined for nonprinting function keys like Enter, Backspace, etc. So you have to expand the conditional to:

if (typeof e != “undefined” && e.keyCode == 13)

01/05/07 11:39AM

Chris Cassell:

Thanks, Rebecca! I’ve updated the script to reflect your input.

01/05/07 7:55PM

Add a Comment

Have something to say about what I wrote here? Let’s hear it!

The Rules

Personal Information




Remember Information


Comment Preview

 

 

Recently Played on iTunes

  1. “Heroin”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:26
  2. “All Tomorrow's Parties”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:20
  3. “Run Run Run”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:16

Last 100 Songs >