List Info

Thread: How to call a javascript in parent page from a Prototype Window?




How to call a javascript in parent page from a Prototype Window?
country flaguser name
United States
2007-09-27 05:48:55
Hello all.

(If some of you are seeing this twice I apologize. After
posting using
Nabble I got an email saying I would have to join the group
to post,
so I joined and re-sent.)

I've been messing around with this all morning. I've looked
at all the
examples ... there doesn't seem to be a mailing list for the
Prototype
Window Class but people seem to know a lot about it on this
list so
I'll try my luck.

I open a Prototype Window and display a list. When the user
clicks on
one of the elements in the list I would like to call a js
function I
have defined in the page that opened the Window. How do I do
this?

I've tried 'old school' parent, parent.opener ... I've also
tried
using observers but they don't seem to be triggering.

Can someone throw me a clue?

Thanks,
Bob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: How to call a javascript in parent page from a Prototype Window?
country flaguser name
United States
2007-09-27 06:43:56
Figured it out myself. There were a few things were messing
me up.

1. I had defined an 'onDestroy' observer, when I needed an
'onClose'
observer.

2. I am using jQuery with Prototype. Since the js function I
was
calling in the parent page was failing I figured it was
Prototype's
fault. It wasn't. Instead of using '$' as I have until now
for my
jQuery stuff I have to use 'jQuery'. (eg. instead of '$
("span#street").html(text);' use
'jQuery("span#street").html(text);')

3. So as it turns out, when you define an observer and stick
js stuff
in it, like function calls, these functions are in the
PARENT page
where you define the window (just as I wanted) not in the
window that
is created.

3. From WITHIN the created window if you call 'top' you have
access to
the parent page, just like in the old days.

That's all. Hope my 'Prototype Window Class for Idiots'
guide helps
someone ...

BOb

On Sep 27, 12:48 pm, syg6 <syg...gmail.com> wrote:
> Hello all.
>
> (If some of you are seeing this twice I apologize.
After posting using
> Nabble I got an email saying I would have to join the
group to post,
> so I joined and re-sent.)
>
> I've been messing around with this all morning. I've
looked at all the
> examples ... there doesn't seem to be a mailing list
for the Prototype
> Window Class but people seem to know a lot about it on
this list so
> I'll try my luck.
>
> I open a Prototype Window and display a list. When the
user clicks on
> one of the elements in the list I would like to call a
js function I
> have defined in the page that opened the Window. How do
I do this?
>
> I've tried 'old school' parent, parent.opener ... I've
also tried
> using observers but they don't seem to be triggering.
>
> Can someone throw me a clue?
>
> Thanks,
> Bob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )