Blocksit插件實(shí)現(xiàn)瀑布流數(shù)據(jù)無限( 異步)加載
來源:易賢網(wǎng) 閱讀:1642 次 日期:2014-07-16 18:49:30
溫馨提示:易賢網(wǎng)小編為您整理了“Blocksit插件實(shí)現(xiàn)瀑布流數(shù)據(jù)無限( 異步)加載”,方便廣大網(wǎng)友查閱!

BlocksIt 瀑布流插件是基于jquery的,使用也非常簡(jiǎn)單,是為數(shù)不多的幾款動(dòng)態(tài)瀑布流插件之一。

html代碼:

<div style="width:1000px; overflow:hidden; margin:0 auto"> 

  <div class="kppcl" style="width:1008px; position:relative" id="kppcl">

    <div class="kppcld">

      <div class="kppcld_t">

        <div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>

        <div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>

        <div class="kinfor">

          <table width="100%" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <th>時(shí)    間:</th>

              <td>{#$item.start_date#}-{#$item.end_date#}</td>

            </tr>

            <tr>

              <th>地    點(diǎn):</th>

              <td>{#$item.area_name#}</td>

            </tr>

          </table>

        </div>

      </div>

      <div class="kppcld_b"></div>

    </div>

    <div class="kppcld">

      <div class="kppcld_t">

        <div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>

        <div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>

        <div class="kinfor">

          <table width="100%" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <th>時(shí)    間:</th>

              <td>{#$item.start_date#}-{#$item.end_date#}</td>

            </tr>

            <tr>

              <th>地    點(diǎn):</th>

              <td>{#$item.area_name#}</td>

            </tr>

          </table>

        </div>

      </div>

      <div class="kppcld_b"></div>

    </div>

    <div class="kppcld">

      <div class="kppcld_t">

        <div class="kpic"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'><img src="{#$item.logo#}" width="322" /></a></div>

        <div class="kname"><a href='{#url_reset("activity/detail","id_{#$item.id#}")#}'>{#$item.title#}</a></div>

        <div class="kinfor">

          <table width="100%" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <th>時(shí)    間:</th>

              <td>{#$item.start_date#}-{#$item.end_date#}</td>

            </tr>

            <tr>

              <th>地    點(diǎn):</th>

              <td>{#$item.area_name#}</td>

            </tr>

          </table>

        </div>

      </div>

      <div class="kppcld_b"></div>

    </div>

  </div>

  <div id="page" style="display: none">

    <div class="pages"><b class="page_icon">上一頁</b><b>1</b><a href="?p=2">2</a><a href="?p=2" class="nextprev" rel="2">下一頁</a></div>

  </div>

</div>

js代碼

<script src="/js/blocksit.min.js"></script>

<script language="javascript" type="text/javascript">

  $(window).load( function() {

    $('#kppcl').BlocksIt({

      numOfCol: 3,

      offsetX: 5,

      offsetY: 5

    });

  });

  var current_p = 0;

  //滾動(dòng)

  $(window).scroll(function(){

    // 當(dāng)滾動(dòng)到最底部以上100像素時(shí), 加載新內(nèi)容

    if ($(document).height() - $(this).scrollTop() - $(this).height()<100) {

      ajax_load_data();

    }

  });

  function ajax_load_data(){

    var next_p = $('#page').find('.nextprev').attr('rel');

    if(next_p && next_p != current_p){

      console.log('nextpage = '+next_p);

      current_p = next_p;

      $.ajax({

        url:'{#url_reset("request/front/ajax","","php")#}',

        data:{'act':'ajax_forum','p':next_p},

        dataType:'json',

        type:'post',

        beforeSend:function(){

          show_loading_body();

        },

        complete:function(){

          show_loading_body();

        },

        success:function(data){

          if(data.status != undefined && data.status == 'ok'){

            if(data.html){

              $('#kppcl').append(data.html).BlocksIt('reload');

            }

            if(data.pages_str){

              $('#page').html(data.pages_str);

            }

          }

        }

      });

    }

  }

</script>

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)