Pop Up Window

Hey Guys, first post here.

I am running into some basic problems. I am trying to submit a form in a popup window and if the object saves close the popup window and refresh the page in the main window.

Has anyone done this, or know a good way to do this?

Sorry for such a stupid question, but I have ran around in circles trying to do this.


The best way to do it, in my mind, is to use an rjs template. In
your controller, your action would look something like this:

def my_action    # do usefull stuff.    ...

     render :update do | page |         if @something.save             page << "myCloseWindowJavaScript()"         else             page << "notifyUserOfError()"         end      end end

where myCloseWindowJavaScript() and notifyUserOfError are javascript
functions you define in a .js file. You can also look at the
documentation for
ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMeth ods

http://api.rubyonrails.org/files/vendor/rails/actionpack/lib/ action_view/helpers/prototype_helper_rb.html