亚洲精品www久久久久久广东,狠色狠色综合久久,蜜臀99久久精品久久久久久软件http://www.aygfsteel.com/fl1429/category/41356.htmlJava,Ruby,Php,Flex,Ajax,UI,Google,Twitter,Firefox,Ubuntu,Opensource,Designer,Blogger,Web2.0zh-cnTue, 02 Mar 2010 15:01:25 GMTTue, 02 Mar 2010 15:01:25 GMT60contentSlider DEMOhttp://www.aygfsteel.com/fl1429/archive/2010/03/01/314196.htmlfl1429fl1429Mon, 01 Mar 2010 11:32:00 GMThttp://www.aygfsteel.com/fl1429/archive/2010/03/01/314196.htmlhttp://www.aygfsteel.com/fl1429/comments/314196.htmlhttp://www.aygfsteel.com/fl1429/archive/2010/03/01/314196.html#Feedback0http://www.aygfsteel.com/fl1429/comments/commentRss/314196.htmlhttp://www.aygfsteel.com/fl1429/services/trackbacks/314196.html Wholesale – Buy China Wholesale Products from Chinese Wholesalers and Factories on BeeBuyer.com


          原文: http://www.wxianfeng.cn/2010/03/01/jquery-div-slider-plugin-contentslider1-0/ 真郁悶 , 我在wordpress中發(fā)表了 demo 會(huì)影響 整個(gè)主題的 樣式, 所以只有放這了 主站蜘蛛池模板: 吴堡县| 靖宇县| 邯郸县| 宁津县| 芷江| 谷城县| 弥勒县| 建平县| 公主岭市| 巴东县| 治县。| 灵宝市| 连州市| 双桥区| 沙洋县| 调兵山市| 门头沟区| 汉沽区| 白玉县| 尤溪县| 托克托县| 黄龙县| 通州市| 改则县| 微山县| 乌兰浩特市| 高清| 新安县| 比如县| 吉林市| 谷城县| 宣汉县| 肃宁县| 郯城县| 徐闻县| 当阳市| 涪陵区| 白玉县| 鹤山市| 青州市| 洞口县|

          ]]>Jquery pagination like twitter more buttonhttp://www.aygfsteel.com/fl1429/archive/2009/09/25/296448.htmlfl1429fl1429Fri, 25 Sep 2009 08:50:00 GMThttp://www.aygfsteel.com/fl1429/archive/2009/09/25/296448.htmlhttp://www.aygfsteel.com/fl1429/comments/296448.htmlhttp://www.aygfsteel.com/fl1429/archive/2009/09/25/296448.html#Feedback0http://www.aygfsteel.com/fl1429/comments/commentRss/296448.htmlhttp://www.aygfsteel.com/fl1429/services/trackbacks/296448.html
          效果和xiaonei的  更多新鮮事  一樣:


          前面有篇文章也介紹了一個(gè)像 twitter more 的方式分頁(yè)的方法,不過(guò)那個(gè)是用 protorype 做的。。那個(gè)做起來(lái)簡(jiǎn)單一點(diǎn),因?yàn)閞ails給我們封裝了 insert_html 和 link_to_remote 等方法,這樣更加便捷,但是解決jquery 和 prototype的confilct是一件很讓人頭疼的事,索性今天又實(shí)現(xiàn)了一個(gè)基于 jquery 的方法,環(huán)境是在rails中,需要使用 will_paginate 插件:
          Demo:

          view:

          <script>
          (function($){
              var settings;

              $.bottomlessPagination = function(callerSettings) {
                  settings = $.extend({
                      ajaxLoaderPath:'/images/loading.gif',
                      results:'.results', // results 返回結(jié)果外部的class
                      objName:'',
                      callback:null
                  },callerSettings||{});
                  settings.imgLoader = new Image();
                  settings.imgLoader.src = settings.ajaxLoaderPath;
                  settings.href = $(".current").next().attr("href"); //current 是 will_paginate 默認(rèn)的當(dāng)前頁(yè) href 的名字

                  if ($('div.pagination').size() > 0){ // pagination 是 will_paginate 默認(rèn)的 class
                      $('div.pagination').wrap("<div class='pagination_links'></div>").hide();
                      $('.pagination_links').append(
                          "<div class='live_pagination'>" +
                          "<a class='more_links' style='cursor:pointer;'> 查看 " + settings.objName + "...</a>" +
                          "</div>"
                          );
                  }
             
                  $(".more_links").click(function(){ 
                      $(".live_pagination").hide();          
                      if ($(".now_loading").size() == 0)              
                          $(".more_links").after("<img class='now_loading' src='"+settings.imgLoader.src+"' />");          
                      else
                          $(".now_loading").show();           
                      $.get(
                          settings.href,'',function(data){
                              $(settings.results).addrows(data);
                              $(".now_loading").hide();
                              $(".live_pagination").show();
                          }
                          );
                      return false;
                  });

                  $.fn.addrows = function(data) {
                      //remove live pagination if there are no more results
                      // alert(data.length);
                      if (data.length === 1 ){
                         // alert(data.length);
                          $('.live_pagination').remove();
                          $('.pagination_links').append(
                              "<div class='no_pagination'>" +
                              "沒(méi)有" + settings.objName +
                              "</div>"
                              );
                          return false;
                      }
                      //change the href
                      ind=settings.href.indexOf("page=");
                      page=parseInt(settings.href.charAt(ind+5))+1;
                      start=settings.href.slice(0,ind+5);
                      stop=settings.href.slice(ind+6);
                      settings.href=start.concat(page.toString()).concat(stop);

                      //add results to the page
                      $(settings.results).append(data);
                      if (settings.callback) settings.callback();
                  };
              };
          })(jQuery);
          </script>


                    <div class="results">
                      <%= render :partial => 'activity' , :collection => @all_feed  %>
                    </div>
                    <%= will_paginate @all_feed  ,
                      :class => 'pagination',          
                      :previous_label => '&laquo; Previous',
                      :next_label     => 'Next &raquo;',
                      :renderer => 'WillPaginate::LinkRenderer' %>
                    <div>
          <div class="now_loading" style="display:none;">
            <img src="http://www.aygfsteel.com/images/loading.gif"></img>
          </div>
          <script>
            $.bottomlessPagination({objName:'更多更新', callback:function(){
                //highlight current row
                //  $("div.results").effect("highlight", {}, 3000);
              }});
          </script>



          Action:
          def index

              if request.xhr?    
                  sleep(1) # make request a little bit slower to see loader :-)   
                    render :partial => 'activity' , :collection => @all_feed
          end


          partial:_activity.html.erb
          partial 里輸出數(shù)據(jù)即可


          主要的注意點(diǎn)就是注意對(duì)應(yīng)class 不要寫錯(cuò)了,同樣,你也可以把class 換位id做,jquery取id就這樣: $("#ID")

          上面js文件下載:
          http://www.dbank.com/download.action?k=3094283bf64e445f9530ac0554ebc9ce

          ref:
          http://github.com/davidwparker/jquery-bottomless-pagination




          ]]>
          Rails Jquery scrolling pagenationhttp://www.aygfsteel.com/fl1429/archive/2009/09/08/294299.htmlfl1429fl1429Tue, 08 Sep 2009 06:29:00 GMThttp://www.aygfsteel.com/fl1429/archive/2009/09/08/294299.htmlhttp://www.aygfsteel.com/fl1429/comments/294299.htmlhttp://www.aygfsteel.com/fl1429/archive/2009/09/08/294299.html#Feedback0http://www.aygfsteel.com/fl1429/comments/commentRss/294299.htmlhttp://www.aygfsteel.com/fl1429/services/trackbacks/294299.htmlruby 1.8.7 + Rails 2.1.0 + ubuntu 8.1.0

          效果:
          http://www.dzone.com/links/index.html
          http://flexidev.co.za/projects/jqpageflow/
          http://paperc.de/documents

          像上面的三個(gè)網(wǎng)站 的分頁(yè)效果 就是 scrolling pagination , 或者 叫 pageless pagination , endless pagination 用這些作為關(guān)鍵字, 都會(huì)搜到很多的demo, 這里我介紹 一種 demo,開(kāi)發(fā) 環(huán)境 是 rails ,of course , 你也可以在其他的平臺(tái)使用。。

          最用 一直在用各種 分頁(yè)的效果,一般都是 ajax的, 例如前面 有介紹了 prototype pagenation like twitter more button, 還有 jquery ajax pagenation,這里又是 jquery scrolling pagination.....

          Demo:

          依賴庫(kù):
          will_paginate 插件
          jquery.js
          jquery.pageless.js

          請(qǐng)到 下面的 那個(gè) ref link 里下

          Action:

           def show
              @client_info = ClientInfo.find(params[:id])
              @comments = @client_info.comments.paginate(:per_page => 5 , :page => params[:page])

              if request.xhr?
                sleep(2) # make request a little bit slower to see loader :-)
                render :partial => 'comment' , :collection => @comments #返回 數(shù)據(jù)的partial
              end
          end


          解釋 : server 端

          helper method :

            # scrolling paginate like greader
            def pageless(total_pages, url=nil)
              opts = {
                :totalPages => total_pages,
                :url        => url
                #:loaderMsg  => '加載中...'
              }
              javascript_tag("$('#ajaxcomments').pageless(#{opts.to_json});")
            end


          解釋; 封裝了一個(gè) pageless 方法,即實(shí)現(xiàn) scrolling load 的的方法

          view: show.html.erb

          ..............
           <%= render :partial => 'wall' %>
          .........................


          解釋 : 前端 view


          partial : _wall.html.erb

            <div class="wall" id ="ajaxcomments">
              <%- unless @client_info.comments.empty? -%>
                <%= render :partial => 'comment', :collection => @comments %>
              <%- end -%>
              <%= will_paginate @comments  ,
                :class => 'pagination',
                :previous_label => '&laquo; Previous',
                :next_label     => 'Next &raquo;',
                :renderer => 'WillPaginate::LinkRenderer' %> <%#= pageless must use will_paginate default style %>
              <%= pageless(@comments.total_pages, client_info_path(@client_info))  %>
            </div>

          解釋 : 注意這里需要 定義 一個(gè) id, 還有 就是 will_paginate 里的那些 參數(shù) 可以 不要 的,這里我加的,是因?yàn)?我的 enviroment.rb 中 加了 will_paginate 的 配置,如果 你沒(méi)有的話, 可以去掉的
          partial : _comment.html.erb
          ..............
          <%= display comment.body %>
          .........................

          解釋 : 顯示的 內(nèi)容

          ref :
          http://github.com/jney/jquery.pageless/tree/master




          ]]>
          rails jquery autocompletehttp://www.aygfsteel.com/fl1429/archive/2009/09/04/293880.htmlfl1429fl1429Fri, 04 Sep 2009 06:40:00 GMThttp://www.aygfsteel.com/fl1429/archive/2009/09/04/293880.htmlhttp://www.aygfsteel.com/fl1429/comments/293880.htmlhttp://www.aygfsteel.com/fl1429/archive/2009/09/04/293880.html#Feedback0http://www.aygfsteel.com/fl1429/comments/commentRss/293880.htmlhttp://www.aygfsteel.com/fl1429/services/trackbacks/293880.html

          記得以前文章寫過(guò) rails autocomplete 插件的使用方法, 那個(gè)是基于 prototype 的, 平時(shí)Jquery用的最多。。所以必須用jquery 實(shí)現(xiàn) , 這樣的 demo 網(wǎng)上太多。。。。下面介紹在rails 中的一種solution

          需要的:
          jquery.js
          jquery.complete.js
          jquery.autocomplete.css

          demo :

          View:

          <script>
            $(document).ready(function() {
              $("#recipient").autocomplete("/myaccount/res_message", {
                delay:10,
                minChar: 1,
                multiple: true,
                parse: function(data) {   
                  return $.map(eval(data), function(item) {
                    return {       
                      data: item,
                      value: item.name,
                      result: item.name
                    }
                  });
                },
                formatItem: function(item) {
                  return item.show;
                }
              }).result(function(e, item)
              {       
                $("#recipient").val(item.name);
              });
            });
          </script>
          <p><%= text_field_tag :recipient, :id => 'recipient' %></p>


          解釋:
          #recipient 是對(duì)應(yīng)的 id
          /myaccount/res_message 對(duì)應(yīng)請(qǐng)求的 url
          item是參數(shù)
          name 和 show 是 返回的變量

          action:
            def res_message

              key = params[:q] if params[:q]
              @result = ClientInfo.get_login_name(key, '' , 'key')
             
              respond_to do |format|
                format.js # default : res_message.js.erb
              end
            end


          解釋 params[:q]  q 是默認(rèn)向后臺(tái)發(fā)送的關(guān)鍵字查詢 參數(shù), 并且默認(rèn)的limit 是10 條數(shù)據(jù)

          view:res_message.js.erb

          <% if @result -%>
          <% i=0 %>[
            <% for result in @result %>
               <% if i==0 %>
              {name:"<%= result.login_name %>",show:"<%= result.login_name + " " %>" + "<%= result.sure_name.nil? ? " " : result.sure_name + " " %>"}
              <% else %>
                ,{name:"<%= result.login_name %>",show:"<%= result.login_name + " " %>" + "<%= result.sure_name.nil? ? " " : result.sure_name + " " %>"}
              <% end %>
                <% i+=1 -%>
            <% end -%>]
          <% end -%>

          解釋: 該view 是返回的數(shù)據(jù),返回的是一個(gè)JSON數(shù)組

          具體詳細(xì)的可以參考:
          http://docs.jquery.com/Plugins/Autocomplete
          http://view.jquery.com/trunk/plugins/autocomplete/demo/


           



          ]]>
          Rails will_paginate ajax pagination with jqueryhttp://www.aygfsteel.com/fl1429/archive/2009/08/25/292522.htmlfl1429fl1429Tue, 25 Aug 2009 07:28:00 GMThttp://www.aygfsteel.com/fl1429/archive/2009/08/25/292522.htmlhttp://www.aygfsteel.com/fl1429/comments/292522.htmlhttp://www.aygfsteel.com/fl1429/archive/2009/08/25/292522.html#Feedback0http://www.aygfsteel.com/fl1429/comments/commentRss/292522.htmlhttp://www.aygfsteel.com/fl1429/services/trackbacks/292522.html
          效果預(yù)覽:


          一般 我們 在rails 中 分頁(yè) will_paginate 是必不可少的插件,但是 一般都是基于 prototype 的,例如 ajax 式的分頁(yè), 通過(guò) RemoteLinkRenderer改變 css 樣式等等,都是 基于prototype 的,但是 prototype 和 Jquery 在項(xiàng)目中 經(jīng)常遇到conflict ,這個(gè) 很 讓人 頭疼,rails 封裝好的ajax方法,好多 都因?yàn)?jquery 不能用,jquery 那么 好 前端 用戶體驗(yàn),又因?yàn)?prototype 出現(xiàn) conflict , 哎 為什么 相互殘殺 呢。。。。。

          上面實(shí)現(xiàn)的核心思想 是 前端 通過(guò) jquery的 異步調(diào)用數(shù)據(jù), 后臺(tái) rails 通過(guò) respond_to fotmat.js 的方式 給予 返回?cái)?shù)據(jù)。。。

          Demo:

          layout 中導(dǎo)入:
              <%= stylesheet_link_tag 'pagination' -%>
              <%= javascript_include_tag 'jquery' %>

          pagination 是改變分頁(yè)的樣式


          Action:

            def index
              @products = Product.paginate(:per_page => 10, :page => params[:page])
              respond_to do |format|
                format.html                        #default : index.html.erb
                format.js {:layout => false} # default : index.js.erb
              end
            end


          View:

          index.html.erb

          <div id="product">
            <%= render :partial => 'products' %>
          </div>

          index.js.erb

          $("#product").html("<%= escape_javascript(render :partial => "products") %>");

          escape_javascript 是轉(zhuǎn)義的意思 和 <%=h %> 這里的 h 差不多

          partial :
          _products.html.erb

          <script>

          $(function() {
            $(".apple_pagination a").live("click", function() {
              $(".apple_pagination").html("Page is loading...");
              $.get(this.href, null, null, "script");
          /* alert(this.href); */
              return false;
            });
          });

          </script>

          <%= will_paginate @products , :class => 'apple_pagination' ,:previous_label => '<<上一頁(yè)', :next_label => '下一頁(yè)>>'   :renderer  => 'WillPaginate::LinkRenderer' %>

          <% for product in @products  %>
            <div class="product">
              <h3>
                <%= link_to h(product.name), product %>
                <%= number_to_currency(product.price) %>
              </h3>
            </div>
          <% end %>


          上面的 $(".apple_pagination a")  即是 will_paginate 的 :class ,:renderer 使用的是will_paginate 的default 的,如果 enviroment.rb 中配置了will_paginate的樣式,這里不寫 :renderer 會(huì)出錯(cuò)!,具體默認(rèn)的參數(shù) 可以查看 will_paginate 下的 view_helpers.rb

          全部 源碼 下載:
          http://www.uushare.com/user/fl1429/file/1941241

          配置方法:
          1,進(jìn)入工程, rake setup
          2,ruby script/server
          3,okay 成功 了。。。。

          補(bǔ)充 : 如果 一個(gè) 頁(yè)面 有兩處需要 分頁(yè),那么 will_paginate 默認(rèn) 情況下 是同時(shí)翻頁(yè)的。。那么 如何 避免呢。。只需要 給各自的 will_paginate 指定 不同的 class 即可  例如

          will_paginate :

          <%= will_paginate collection ,
            :class => "apple_paginate my_paginate",
            :previous_label => '<<上一頁(yè)',
            :next_label => '下一頁(yè)>>' ,
            :renderer  => 'WillPaginate::LinkRenderer'  %>

          apple_paginate 是 分頁(yè)的真正的 css,my_paginate 是為了 區(qū)別 不同區(qū)的 分頁(yè) 而加的


          jquery script :
            jQuery(function() {
              jQuery(".my_paginate a").live("click", function() { 
                jQuery(".my_paginate").html("正在加載...");
                jQuery.get(this.href, {flag : "my" }, null, 'script');
                return false;
              });
            });

          注意 jquery get 方法的 四個(gè)參數(shù) 的 意義

          ref:
          http://railscasts.com/episodes/174-pagination-with-ajax
          http://soylentfoo.jnewland.com/articles/2007/09/17/resource_this-dry-rails-resource-controllers
          http://book.csdn.net/bookfiles/375/10037514155.shtml
          http://stackoverflow.com/questions/1268383/format-js-with-rails





          ]]>