views:

39

answers:

3

So.. I have this in the action called when someone clicks the archive button

respond_to do |format|
  format.js do
    render :update do |page|
      page << "alert('You have reached your archive object limit. You have #{remaining} remaining archived objects.');"
      end
    end
 end

But instead of alerting, it just gets rid of the entire page and shows a JavaScript try / catch with that alert message. How do I just do an alert without rendering anything?

+1  A: 

Add

:layout => false

in render

A: 

If it's an AJAX call, you may do something like this in your action:

render :text => "<script type='text/javascript'>alert('bla');</script>"
buru
it action makes the browser navigate away from the page... so... i added a redirect. but I can only have one
DerNalia
+1  A: 

Needed to change form_for to form_remote_for to enable ajax

DerNalia