How to get your controller to close a browser popup window

While editing a record I need to have a link to create a new record in
another scaffold.

I’ve done this by using a popup window

<%= link_to(“Add new Person”, “/person/new”, :popup => [‘window_name’,
‘width=600,height=600’]) %>

It all works great - but when the save is done I want to kill the popup
window.

I’ve got the Cancel button to close the window by using this
Close the window

But how can I get the controller to force a close?

how about do it in ajax-like way. in the return page you can write
javacript
callback function. what do you think?

zee ho wrote:

how about do it in ajax-like way. in the return page you can write
javacript
callback function. what do you think?

sounds good… do you know how? i’ve got some ajax stuff in my project
but I don’t understand it to be honest!

jh100000 wrote:

zee ho wrote:

how about do it in ajax-like way. in the return page you can write
javacript
callback function. what do you think?

sounds good… do you know how? i’ve got some ajax stuff in my project
but I don’t understand it to be honest!

Here’s an example.

Sorry for the dopey names, I just copied this out of some stuff I was
testing the other day:

In my rhtml file, I had

<%=link_to_remote “Blurt”, :url => { :action => “blurt”}%>


<%=link_to_remote “Flurb”, :url => { :action => “flurb”}%>


In my controller, I had

def blurt
render :update do |page|
page << ‘mywindow = window.open(“http://url.for.source.com”, “A
Window”)’
end
end

def flurb
render :update do |page|
page << ‘mywindow.close()’
end
end

–Al Evans

Cheers Al,

that’s neat - and nearly what I need - but not quite…

So now I’ve got a link_to_remote on view X which pops up a new window
with a view of controller Y.

What i really need is a “closeme” function.