Has anyone seen how to do pop-ups via controllers?

I’ve got the pop-up window opening if I click on a link, but now I want
to do something else. After a record is created, I want to go the edit
page and open up a pop-up window. Any ideas on how to make that work?

Thanks!

Hi

Its not the right method to call a popup from controller…IF you want
to do that u an put onwindow load u can call the function of popup on
the edit page.

Thanks

Dhaval P.
Software Engineer

sales(AT)railshouse(DOT)com

Prior to opening the pop-up window I need to save a new record. What’s
the best way to open that window after a record has been successfully
saved. If it fails, that window should not open.

What Dhaval is saying is that a server cannot directly request that a
browser open a pop-up window–the request must come from the browser.
Believe me, everyone except spammers are very glad that is the case.

What you may be able to do is use RJS templates to send a javascript
pop-up script to the browser (or simply an alert() depending on your
requirements).

– Mark.

Its not the right method to call a popup from controller…IF you want
to do that u an put onwindow load u can call the function of popup on
the edit page.

Prior to opening the pop-up window I need to save a new record. What’s
the best way to open that window after a record has been successfully
saved. If it fails, that window should not open.

thanks.

After a record is created, I want to go the edit
page and open up a pop-up window. Any ideas on how to make that work?

What are you calling a popup? I don’t know anyone that doesn’t have a
popup blocker.

Without a redirect, I think you could do this with a YUI panel or
extJS panel that gets opened based on the results of an AJAX call.

However, if I hear you correctly, “Go to the edit page” is a redirect
which makes this easier. You have a new page!

I haven’t done this, but if you are going redirect to a new (edit)
page, I should think that you could pass a parameter to the “edit
view” that tells the view to open a YUI panel Like this:

http://developer.yahoo.com/yui/examples/container/panel-resize_source.html

Good luck

What are you calling a popup? I don’t know anyone that doesn’t have a
popup blocker.

Without a redirect, I think you could do this with a YUI panel or
extJS panel that gets opened based on the results of an AJAX call.

However, if I hear you correctly, “Go to the edit page” is a redirect
which makes this easier. You have a new page!

This is actually an internal application so the pop-up window is not a
problem. The pop-up window is pick list to add to an order. The pop-up
list works off of an order number so if it’s a new order, an order needs
to be created first. After the new order is created, I want to refresh
the order page so that it’s in edit mode to continue entering in the
order AND enable the user to select values in the pop-up window.

Does that make sense?

What you may be able to do is use RJS templates to send a javascript
pop-up script to the browser (or simply an alert() depending on your
requirements).

I am getting an error somewhere and am not sure what it means.

I have this in my template - <%= javascript_include_tag :defaults -%>

I’m guessing that this is an error in my controller.

def create
respond_to do |format|
format.html {render :update do |page|
page.call(‘popup’)
end
}
end
end

I then get this output on the following page

try {
popup();
} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘popup();’);
throw e }

Any help to fix what I’m doing wrong is appreciated.

That looks like you are sending an ajax response to a normal page
request. ie. did the request come from a browser ajax call, or a
normal link or form submit. To send javascript to the page using the
render :update, you need to use link_to_remote or form_remote etc. in
your view.

try {
popup();} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘popup();’);

throw e }

Any help to fix what I’m doing wrong is appreciated.

Posted viahttp://www.ruby-forum.com/.

As regards your popup question, the earlier suggestion from Dvahal of
using the javascript onwindow load in your Edit view would seem a fair
way to go. In the edit template, you can conditionally include the
javascript call depending on whether the order being displayed is
considered a new one.

Tonypm