<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: RJS code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 29 Aug 2008 22:26:28 GMT</pubDate>
    <description>DZone Snippets: RJS code</description>
    <item>
      <title>how to escape from AJAX URL</title>
      <link>http://snippets.dzone.com/posts/show/1705</link>
      <description>From Dylan Stamat's post on the Ruby on Rails list 	&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Within my "login.rjs" template that get's invoked after my login process, it returns to the same page with an error message on error, or... if the login was successful, it needs to "redirect" to another controller... which is pretty much impossible to do otherwise.  so, my " login.rjs" looks like:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;if @logged_in_client&lt;br /&gt;  page.replace_html "message", :partial =&gt; 'shared/bad_login'&lt;br /&gt;else&lt;br /&gt;  page.redirect_to "whatever you want here"&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;------ End Message--------&lt;br /&gt;Here is my two cents:&lt;br /&gt;Technically, you can do this without a RJS template at all, because it is such a simple example. Use this in your controller&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;render :update do |page|&lt;br /&gt;  if @logged_in_client&lt;br /&gt;    page.replace_html "message", :partial =&gt; 'shared/bad_login'&lt;br /&gt;  else&lt;br /&gt;    page.redirect_to "whatever you want here"&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 16 Mar 2006 08:42:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1705</guid>
      <author>heavysixer ()</author>
    </item>
  </channel>
</rss>
