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:
----------JS--------------------
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
}
});
event.preventDefault();
}
function addObservers() {
$('searchForm').observe('submit', doSearch);
}
Event.observe(window, 'load', addObservers);
-----form HTML--------
Search
<form method="post" id="searchForm" style="display: inline">
<input type="text" name="txt" id="txt" size="20"/>
<input type="submit" name="btnSubmitSearch" id="btnSubmitSearch"
value="Go!"/>
</form>
-----------HTML----------
<body>
<div id="search"> <!-- stuff here either inserted via ruby ajax
post OR hardcoded -->
</div>
<div id="menu">
</div>
</body>
------------------
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.
Thanks
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---