对滚动条添加JS事件

 

 

jQuery(function (){
        var i = 2;
        jQuery("#doctor_list").bind("scroll", function (event) {
   var obj = document.getElementById("doctor_list");
   var flag = document.getElementById('flag').value;
   if (((obj.scrollHeight - obj.scrollTop) <= 700) && (flag == "1") && ($('add_ajax').value == '1'))
   {
    $('add_ajax').value = '0';
    add_data(i);
    i++;
   }
  });
 });
 
 function add_data(i){
  var a_data = document.getElementById("ddata_span");
  var flag = document.getElementById('flag').value;
  if (flag == "1") {
   a_data.innerHTML = "<table><tr><td><img src='/images/loading.gif' />&nbsp;&nbsp;</td><td><font size='2'>読み込み中...</font></td><tr/></table>";
   new Ajax.Request("/admin/doctor/add_data", {
    asynchronous: true,
    evalScripts: true,
    parameters: 'page=' + i + '&branch=<%=params[:branch]%>&office=<%=params[:office]%>&user=<%=params[:user]%>',
   });
  }
 };

 

posted @ 2013-01-22 14:06  残星  阅读(690)  评论(0编辑  收藏  举报