2012年8月21日火曜日

Get data Like a twitter scroll on Ruby on Rails3

Environment

ruby-1.9.3-p0, rails3.2.2, postgres

Grade

normal


I created a mechanism that Application get data like a twitter scroll.
In case of Rails 3, you should use jquery.pageless. This is help you to create Endless Page Scrolling.

If you search Endless Page Scrolling way on Internet, you find Endless Page on rails cast or Endless Page Scrolling with Rails 3 and jQuery.
But, you should avoid using these ways.
Because "Endless Page" article does not support jquery on rails3. If you use rails2.x, this way is very good.
"Endless Page Scrolling with Rails 3 and jQuery" article is not simple. This code is complicated.

how to use jquery.pageless

Download jquery.pageless file. set some files on your application. you have only to imitate sample.
But, if will_paginate gem does not exist, this tools does not work.
jquery.pageless need will_paginate gem.

how to change loading view

If you use jquery.pageless, you are able to create view like a twitter scroll. but I think you want to change load view.
At that case, you should change part of jquery.pageless.


  var loaderHtml = function () {
    return settings.loaderHtml || '\
<div id="pageless-loader" style="display:none;text-align:center;width:100%;">\
  <div class="msg" style="color:#000000;font-size:1.1em"></div>\
  <img src="' + settings.loaderImage + '" alt="loading more results" style="margin:10px auto" />\
</div>';
  };

you can change here font size, color, load view.

This is very useful. I will recommend.

Thanks for reading. bye!


helping site

この記事がお役にたちましたらシェアをお願いします

このエントリーをはてなブックマークに追加

0 件のコメント:

コメントを投稿

Related Posts Plugin for WordPress, Blogger...