How call alert method from controller (something like rende :ajax => 'some text') ?

Yeah,

I’m needing to show a popup window after the execution of method. I’m trying something like:

def bla respond_to do |format| format.html { redirect_to … } format.js

end end

bla.rjs

page.alert(‘some text’)

How can i do it?

Thanks for your attention!

Use the render command in your controller. Remember that you can render or redirect only once per action. Look at api.rubyonrails.org for more options.

render :update do |page|   page.alert "hi" end

mukund,

That’s ok. I tried it after, and get:

try {
alert("some text...");
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('alert(\"some text...\");'); throw e }

Regards, Luiz Vitor.

mukund,

That's ok. I tried it after, and get:

try { alert("some text..."); } catch (e) { alert('RJS error:\n\n' + e.toString());
alert('alert(\"some text...\");'); throw e }

That's looks like the right javascript. What's wrong?

Fred

Fred,

Why it don’t shows the pop-up containing “some text…” message?

Regards, Luiz Vitor.

Fred,

Why it don’t shows the pop-up containing “some text…” message?

What does your link_to_remote ( or whatever it is you are using to invoke the action) look like? If you’re passing an :update option, don’t.

Fred