# Anybody know a prototype helper that creates a popup window?

**URL:** <https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548>\
**Category:** Rails\
**Created:** [June 16, 2008, 4:26am UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548 "2008-06-16T04:26:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 16, 2008, 4:26am UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/1 "2008-06-16T04:26:55Z")

</div>

Hi,

I’m trying to get a form to open up in a new window. I know how to  
toggle divs but haven’t been able to find anything on how to get  
another window to open…any ideas?

Ron

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 16, 2008, 4:37am UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/2 "2008-06-16T04:37:26Z")

</div>

So I realized after I posted this that thre is a :popup option in  
link\_to. but for some reason when I add it to my links, it just loads  
a full page, not a popup. I’ve included javascript on my layouts…I  
heard somewhere that there is a prototype window–something different  
from a pop up window. Anybody know anything about that type of  
window?

Ron

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 16, 2008, 9:59am UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/3 "2008-06-16T09:59:30Z")

</div>

On Jun 16, 3:37 am, Ron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So I realized after I posted this that thre is a :popup option in  
> link\_to. but for some reason when I add it to my links, it just loads  
> a full page, not a popup. I’ve included javascript on my layouts…I  
> heard somewhere that there is a prototype window–something different  
> from a pop up window. Anybody know anything about that type of  
> window?

window.open(url, …)

I suspect that when people mean prototype window they actually mean a  
chunk of html that has been styled to look like a window within the  
window (and normally scripted so that you can move it around, resize  
it etc…)

Fred

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 17, 2008, 7:35pm UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/4 "2008-06-17T19:35:30Z")

</div>

Hi Fred,

So I guess I’m not sure what the syntax would be?  
\<%=link\_to\_remote ‘Link’, "window.open(?)%\>  
?

On Jun 16, 12:59 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 17, 2008, 9:43pm UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/5 "2008-06-17T21:43:33Z")

</div>

On 17 Jun 2008, at 18:34, Ron wrote:

> Hi Fred,
> 
> So I guess I’m not sure what the syntax would be?  
> \<%=link\_to\_remote ‘Link’, "window.open(?)%\>  
> ?

Nope, what you want is link\_to\_function (which is just fancy pants for

Fred

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [June 19, 2008, 7:14pm UTC](https://www.ruby-forum.com/t/anybody-know-a-prototype-helper-that-creates-a-popup-window/140548/6 "2008-06-19T19:14:28Z")

</div>

Okay Fred…that makes more sense. That’s really helpful. Thanks, as  
always.

As for the Prototype windows, I’ve managed to get a nice window to  
open using Prototype Window. Its a really nice library that tacks on  
to Prototype the ability to generate Prototype-based windows. Its  
here: [http://prototype-window.xilinus.com/index.html](http://prototype-window.xilinus.com/index.html)

I included a couple of Javascript files in my javascript folder and  
then defined a javascript variable in my view:  
win = new Window({className: “mac\_os\_x”, title: “Sample”, width:200,  
height:150, destroyOnClose: true, recenterAuto:false});  
win.getContent().update(“

# Hello world !!
”);

Then I passed win.showCenter(); to a link\_to\_function tag:  
\<%=link\_to\_function ‘Add Paper,’ “win.showCenter();”%\>

Voila! (This code, btw, is from the sample on Prototype Window’s  
site).

There are several themes that you can use; I had to copy the  
stylesheet to the public/stylesheets directory along with a directory  
of image files for the particular theme. I’m going to customize the  
theme for my app; however, I was just trying to get started.

The only thing I’m not sure about here–maybe someone else knows–is  
how to pass a Rails generated URL to the Window. Right now, I can  
only get it to show a div on the page or HTML I provide to it. But  
there is a getURL method that accepts a string argument that I’d like  
to use. When I try and put a link tag helper in, however, the script  
doesn’t work. I’m thinking maybe if I used RESTful routes, the path  
would be a string variable (if I’m not mistaken)–making it perhaps  
acceptable as an argument.

Any ideas? I mean, for this to work, its pretty important to be able  
to show windows that have views in the Rails App. I’ve got to figure  
out how to get this going somehow.

Ron

On Jun 17, 12:43 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
