When I hardcode a form into a div and try to get a handle on it via $
('') it works. When I include the txt dynamically via an AJAX update()
it doesnt:

function doUpdate(id, url) {
  new Ajax.Updater(id, url);

doUpdate('search', 'search');
doUpdate('menu', 'menu');

function doSearch(event) {
  new Ajax.Updater('menu', 'menu', {
  parameters: {
    txt: $('txt').value

function addObservers() {
  $('searchForm').observe('submit', doSearch);

Event.observe(window, 'load', addObservers);

-----form HTML--------
<form method="post" id="searchForm" style="display: inline">
        <input type="text" name="txt" id="txt" size="20"/>
        <input type="submit" name="btnSubmitSearch" id="btnSubmitSearch"

  <div id="search">      <!-- stuff here either inserted via ruby ajax
post OR hardcoded -->

  <div id="menu">

Now I get $('searchForm') is null when i use doUpdate('search',
'search'); - gets it via ruby http post
If however i comment out "doUpdate('search', 'search');" and instead
actually hardcode into the div

I looked into defer() but it didn't help.


You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to