Hi
I am a real beginner with prototype so sorry this is a real beginners
question!
I have a page I want to update dynamically when a link is clicked, and
different content (supplied from a php script) according to which
link. I was thinking to pass the id of the link to the script and use
Ajax.Updater.
So far I have this but it doesn't quite work:
function doSwap(page) {
new Ajax.Updater('fruit', 'gimme.php', {
method: 'get', parameters: page=$ });
return false;
}
<div id="fruit">
<p>Content</p>
</div>
<a href="#" id="toggle1" onclick="doSwap(); return false;">toggle1
baby</a>
<a href="#" id="toggle2" onclick="doSwap(); return false;">toggle2
baby</a>
<a href="#" id="toggle3" onclick="doSwap(); return false;">toggle3
baby</a>
<a href="#" id="toggle4" onclick="doSwap(); return false;">toggle4
baby</a>
on 2008-06-19 04:08
on 2008-06-19 04:27
Your links are calling doSwap() with no parameters, so page will be undefined. Also, your syntax of parameters: page=$ was... well, not sure what you were trying to do there. See edits below. I assume you want to pass the ID as the value of the page param? I'm passing this as a parameter to doSwap, which will be a reference to the <a> element which was clicked. Then the function extracts the link ID to form the parameters string. And your function doesn't need to return false if your onclick returns false. Alternatively, you could say onclick="return doSwap(link)" and put the return false; back in. -Fred On Wed, Jun 18, 2008 at 9:08 PM, McBlaue <emrys.hughes@gmail.com> wrote: > > <a href="#" id="toggle1" onclick="doSwap(this); return false;">toggle1 > baby</a> > <a href="#" id="toggle2" onclick="doSwap(this); return false;">toggle2 > baby</a> > <a href="#" id="toggle3" onclick="doSwap(this); return false;">toggle3 > baby</a> > <a href="#" id="toggle4" onclick="doSwap(this); return false;">toggle4 > baby</a> -- Science answers questions; philosophy questions answers.
on 2008-06-19 09:37
Sorry to be a pain in the arse guys, but AJAX.Updater doesn't seem to work at all on IE/Opera. Please see another thread on AJAX.Updater and IE. Luis Pabón
on 2008-06-19 12:56
Can you be more specific? I worked on a major project for the last 9 months that made heavy use of Ajax.Updater in IE. -Fred On Thu, Jun 19, 2008 at 2:37 AM, Luis Pabón <copong@gmail.com> wrote: > Sorry to be a pain in the arse guys, but AJAX.Updater doesn't seem to work > at all on IE/Opera. Please see another thread on AJAX.Updater and IE. > > Luis Pabón -- Science answers questions; philosophy questions answers.
on 2008-06-19 13:10
Hi, On Jun 19, 8:37 am, "Luis Pabón" <cop...@gmail.com> wrote: > Sorry to be a pain in the arse guys, but AJAX.Updater doesn't seem to work > at all on IE/Opera. Please see another thread on AJAX.Updater and IE. Pull the other one, it's got bells on. Of course it works in IE and Opera. Just because some user is having some problem somewhere (which is almost certainly in his code, not the library), there's no need to cross-pollute threads with statements like "it doesn't work in IE/ Opera". That's not useful, accurate, or appropriate. Even if the problem he's running into turns out to be a bug in the library in some specific situation (which is possible, just unlikely), that's a far cry from "it doesn't work." -- T.J. Crowder tj / crowder software / com
on 2008-06-19 13:36
Please see my last emails with a test case in here: http://groups.google.com/group/rubyonrails-spinoff... I may be doing something inherently wrong on te test case, but looks straightforward enough to me. Cheers, Luis
on 2008-06-19 14:32
Luis, So discuss it over there. See above about cross-polluting. The lack of replies in that thread is not a reason to hijack other threads. -- T.J. Crowder tj / crowder software / com
on 2008-06-19 15:02
Fair enough. It wasn't my intention to hijack this thread, I thought it was relevant mentioning that updater may not work on ie since this user is trying to use it (although incorrectly as far as I can see). Luis Pabón 2008/6/19 T.J. Crowder <tj@crowdersoftware.com>: