ken
ken

Reputation: 75

Prototype.js error - 'undefined' is null or not an object

I am getting following error in Prototype.js

'undefined' is null or not an object line 5557 char 5

which is this:

var respondersForEvent = registry.get(eventName);
    if (Object.isUndefined(respondersForEvent)) {
      respondersForEvent = [];
      registry.set(eventName, respondersForEvent);
    }

How can i fix this?

Here is the code giving error:

Event.observe(window, "load", function () { 
    Event.observe("query", "keypress", function (e) { 
        if (e.keyCode == Event.KEY_RETURN) { 
            search(); 
        } 
    }); 
}); 

It says error is on keypress.

Upvotes: 4

Views: 5575

Answers (2)

ThreeCheeseHigh
ThreeCheeseHigh

Reputation: 1498

Had the same problem, look for duplicate javascript code. In my case I had included the mini search form of Magento and its related javascript twice:

<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form_new', 'search', '<?php echo $this->__('Search entire store here...') ?>');
searchForm.initAutocomplete('<?php echo $this->helper('catalogsearch')->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script> 

Hope this help anyone with same problem.

Upvotes: 0

Samir Talwar
Samir Talwar

Reputation: 14330

Do you have an element with the ID "query"? Note that it cannot just have a name attribute—for the code you have provided, it must have "query" as the id attribute. A valid example would be:

<input type="text" id="query" />

Upvotes: 1

Related Questions