AJAX loading notice based on Prototype

Loading Notice is a javascript plugin, built on Prototype, which automatically shows an indictor when a slow AJAX is under process. Basically, it’s like the “loading” div appears in gmail when busy. And when the users scroll or resize the window, it will still keep showing on the top of the page.

Check it out here: http://github.com/shaokun/loading_notice/tree/master

HOWTO

1. Install the plugin:

$ ruby script/plugin install git://github.com/shaokun/loading-notice.git
$ rake loading_notice:install

2. Include the library into your project:

<%= javascript_include_tag 'prototype', 'loading_notice' %>
<%= stylesheet_link_tag 'loading_notice' %>

3. Add a “loading” div and initialize a javascript object:

<div id="loading" style="display: none">Loading...</div>

<script type="text/javascript">
  window.onload = function() {
    window.loading_notice = new LoadingNotice("loading");
  }
</script>

4. That’s all!

Posted by Shaokun Mon, 20 Jul 2009 05:55:00 GMT


Comments

  1. adeh about 1 hour later:
    Hey, what about making a rails helper so I can just do.
    <%=loading_notice('等一下')%>
  2. shaokun about 23 hours later:
    yep, sounds like a good idea!