1

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?

2
  • What does the code look like on the view, where they click the archive button? Commented Jul 13, 2010 at 16:16
  • Problem was that I wasn't using a from_remote_tag Commented Jul 13, 2010 at 17:23

3 Answers 3

1

Add

:layout => false

in render

Sign up to request clarification or add additional context in comments.

Comments

1

Needed to change form_for to form_remote_for to enable ajax

Comments

0

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

render :text => "<script type='text/javascript'>alert('bla');</script>"

1 Comment

it action makes the browser navigate away from the page... so... i added a redirect. but I can only have one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.