Forum: Rails Spinoffs (closed, excessive spam) updating a div

5a7d564c78d957ec2aac87ccea2c8b3c?d=identicon&s=25 McBlaue (Guest)
on 2008-06-19 04:08
(Received via mailing list)
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>
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-19 04:27
(Received via mailing list)
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.
F96bf09dc0f285c579068a8937f07d14?d=identicon&s=25 Luis Pabón (Guest)
on 2008-06-19 09:37
(Received via mailing list)
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
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-19 12:56
(Received via mailing list)
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.
Ca3e484c121268e4c8302616b2395eb9?d=identicon&s=25 T.J. Crowder (Guest)
on 2008-06-19 13:10
(Received via mailing list)
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
F96bf09dc0f285c579068a8937f07d14?d=identicon&s=25 Luis Pabón (Guest)
on 2008-06-19 13:36
(Received via mailing list)
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
Ca3e484c121268e4c8302616b2395eb9?d=identicon&s=25 T.J. Crowder (Guest)
on 2008-06-19 14:32
(Received via mailing list)
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
F96bf09dc0f285c579068a8937f07d14?d=identicon&s=25 Luis Pabón (Guest)
on 2008-06-19 15:02
(Received via mailing list)
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>:
Ca3e484c121268e4c8302616b2395eb9?d=identicon&s=25 T.J. Crowder (Guest)
on 2008-06-19 15:45
(Received via mailing list)
Well, FWIW for anyone still lurking on this thread, Fred's corrected
code works fine on IE6, Opera 9, FF3, and Safari 3.1 (on Windows XP).

-- T.J.
This topic is locked and can not be replied to.