<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>has_no :sorrow</title>
	<atom:link href="http://hasnosorrow.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hasnosorrow.wordpress.com</link>
	<description>another rails weblog</description>
	<lastBuildDate>Mon, 13 Oct 2008 21:18:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hasnosorrow.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>has_no :sorrow</title>
		<link>http://hasnosorrow.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hasnosorrow.wordpress.com/osd.xml" title="has_no :sorrow" />
	<atom:link rel='hub' href='http://hasnosorrow.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ajaxify wil_paginate with lowpro</title>
		<link>http://hasnosorrow.wordpress.com/2008/10/13/ajaxify-wil_paginate-with-lowpro/</link>
		<comments>http://hasnosorrow.wordpress.com/2008/10/13/ajaxify-wil_paginate-with-lowpro/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 21:17:17 +0000</pubDate>
		<dc:creator>Guillaume</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[lowpro]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[will_paginate]]></category>

		<guid isPermaLink="false">http://hasnosorrow.wordpress.com/?p=5</guid>
		<description><![CDATA[Here&#8217;s the case - I am in rails; - I am in a search page that displays two types of results: videos and profiles; - Each are paginated thanks to will_paginate; - I want to use videos and profiles with ajax, not to modify the rest of the web page. Solution First of all, I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hasnosorrow.wordpress.com&amp;blog=5164589&amp;post=5&amp;subd=hasnosorrow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Here&#8217;s the case</strong><br />
- I am in rails;<br />
- I am in a search page that displays two types of results: videos and profiles;<br />
- Each are paginated thanks to will_paginate;<br />
- I want to use videos and profiles with ajax, not to modify the rest of the web page.</p>
<p><strong>Solution</strong><br />
First of all, I include the lowpro library in my layout to think unobstrusive about javascript:</p>
<pre><code>&lt;%= javascript_include_tag 'lowpro' %&gt;</code></pre>
<p>Here is my controller:</p>
<pre><code>class SearchController &lt;  ApplicationController
  def index
    @profiles = Profile.search params[:query] :page =&gt; (params[:profile_page] || 1)
    @videos = Video.search params[:query], :page =&gt; (params[:video_page] || 1)

    respond_to do |format|
      format.html
      format.js do
        render :update do |page|
          if params[:profile_page]
            page.replace_html 'profiles', :partial =&gt; "profiles"
          elsif params[:video_page]
            page.replace_html 'videos', :partial =&gt; "videos"
          end
        end
      end
    end
  end
end</code></pre>
<p>Here is my view:</p>
<pre><code>&lt;div id="profiles"&gt;
	&lt;%= render(:partial =&gt; 'profiles') %&gt;
&lt;/div&gt;
&lt;div id="videos"&gt;
	&lt;%= render(:partial =&gt; 'videos') %&gt;
&lt;/div&gt;
&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
Event.addBehavior.reassignAfterAjax = true;
Event.addBehavior({
	'#profiles_pagination a' : Remote.Link
})
Event.addBehavior({
	'#videos_pagination a' : Remote.Link
})
//]]&gt;
&lt;/script&gt;</code></pre>
<p>And last, one of my partial:</p>
<pre><code>&lt;h3&gt;Profiles&lt;/h3&gt;
&lt;% for profile in @profiles -%&gt;
&lt;%= link_to profile.name, show_profile_path(profile.name) %&gt;
&lt;% end %&gt;
&lt;%= will_paginate @profiles, :param_name =&gt; 'profile_page', :id =&gt; true %&gt;</code></pre>
<p><strong>Done</strong><br />
But&#8230; don&#8217;t hesitate to comment, question or suggest improvements.</p>
<p>Thanks,<br />
Guillaume</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hasnosorrow.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hasnosorrow.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hasnosorrow.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hasnosorrow.wordpress.com&amp;blog=5164589&amp;post=5&amp;subd=hasnosorrow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hasnosorrow.wordpress.com/2008/10/13/ajaxify-wil_paginate-with-lowpro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a89046d7bfa50f42e45bff501daa57f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilo78</media:title>
		</media:content>
	</item>
		<item>
		<title>puts &#8220;nice to meet&#8221;</title>
		<link>http://hasnosorrow.wordpress.com/2008/10/13/puts-nice-to-meet/</link>
		<comments>http://hasnosorrow.wordpress.com/2008/10/13/puts-nice-to-meet/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 20:53:35 +0000</pubDate>
		<dc:creator>Guillaume</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://hasnosorrow.wordpress.com/?p=3</guid>
		<description><![CDATA[I&#8217;ve just created this blog since I wanted to share a bit of rails code (see next post) about the will_paginate plugin. I am not sure how much and good I&#8217;ll be posting down here&#8230; It just starts as a non-guru rails developer sharing casual solutions to casual problems he met.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hasnosorrow.wordpress.com&amp;blog=5164589&amp;post=3&amp;subd=hasnosorrow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just created this blog since I wanted to share a bit of rails code (see next post) about the will_paginate plugin. I am not sure how much and good I&#8217;ll be posting down here&#8230; It just starts as a non-guru rails developer sharing casual solutions to casual problems he met.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hasnosorrow.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hasnosorrow.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hasnosorrow.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hasnosorrow.wordpress.com&amp;blog=5164589&amp;post=3&amp;subd=hasnosorrow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hasnosorrow.wordpress.com/2008/10/13/puts-nice-to-meet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a89046d7bfa50f42e45bff501daa57f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">kilo78</media:title>
		</media:content>
	</item>
	</channel>
</rss>
