html - 如何动态使用滚动功能数据来自页脚

标签 html jquery jquery-mobile

我必须在页脚中使用滚动功能,其中数据动态存储在按钮中,并且滚动应该隐藏,然后我们再次滚动它显示,所有数据和滚动应该动态加载在页脚中,只有窗口屏幕不应仅更改页脚将在滚动时改变

在 jquery 中:-

 function callXMLConnection() {  

        $.support.cors = true;
           $.ajax({
                type: "GET",
                url: "url.html",
                contentType: "text/xml",
                dataType: "xml",
                data: "",
                cache:false,
                processData:false,
                crossDomain:true,
                success: processSuccess,

            });

      }


      function processSuccess(data) {

             $(data).find("category").each(function () {

             var id = $(this).find('id').text();
             var title = $(this).find('title').text();
             var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true'>"+title+"</a>"                
            $("#menu_button1")
             .append(scripts)
             .trigger('create');
         });
      }
   $(document).unbind('ready').bind('ready', function () {
     $("#menu_button1").scroll(function () {
     // if ($("#menu_button1").scrollLeft(300) == $(document).width() - $("#menu_button1").width()) 
     if ($("#menu_button1").scrollHeight - $("#menu_button1").scrollTop() == $("#menu_button1").outerHeight())
     {
       callXMLConnection(); 
   }
});

     });

在 html5 中:-

<div data-role="footer" data-position="fixed" id="scroll_menu" style="overflow: scroll;">
              <div class="menu" id="menu_button1" ></div>
</div>

最佳答案

终于我得到了这些的答案

在 HTML5 中:-

 <div data-role="page" data-theme="b" id="jqm-home">    
      <div data-role="footer" data-position="fixed" data-theme="c">        
           <div  class="categories" id="cat">                
              <ul id="cat_list" class="cat_list_class"></ul>               
           </div>
      </div>    
</div>

在 jquery 中:-

 var step = 1;
 var current = 0;
 var maximum = 0;
 var visible = 2;
 var speed = 500;
 var liSize = 120;
 var height = 60;    
 var ulSize = liSize * maximum;
 var divSize = liSize * visible;

 $(document).unbind('pageinit').bind('pageinit', function () {    
      callMenuConnection(); 
       $('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
       $(".categories ul a").css("list-style","none").css("display","inline");
       $(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");      
  });

 $(document).unbind('click').bind('click', function () {
        scroll();
 });
   function callMenuConnection() {  
       $.support.cors = true;
       $.ajax({
            type: "GET",
            url: "one.html",
            contentType: "text/xml",
            dataType: "xml",
            data: "",
            cache:false,
            processData:false,
            crossDomain:true,
            success: processSuccess,
            error: processError
        }); 
  }
      var scripts ="";     
  function processSuccess(data) {
         $(data).find("category").each(function () {     
         var id = $(this).find('id').text();
         var title = $(this).find('title').text();
          scripts = scripts+'<a  class="ids_cat" data-role="button" data-transition="slide"  data-inline="true" >' +title+ '</a>';
        });
        $('#cat_list').append(scripts);
        $('#cat_list').trigger('create');
         maximum = $(".categories ul a").size();
  }

     function processError(data)
       {
           alert("error");
       }

 function scroll(){ 
 $(".categories").swipeleft(function(event){
  if(current + step < 0 || current + step > maximum - visible) {return; }
else {
    current = current + step;
    $('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});

  $(".categories").swiperight(function(event){
    if(current - step < 0 || current - step > maximum - visible) {return; }
        else {
      current = current - step;
       $('.categories ul').animate({left: -(liSize * current)}, speed, null);
    }
   return false;
   });         
 }

关于html - 如何动态使用滚动功能数据来自页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17696903/

相关文章:

html - 使用位置 :absolute on child divs sticks them together into one place

javascript - 如何删除日期时间本地输入类型中的时间值?

javascript - 使用后退按钮后如何从上一页获取单选值?

javascript - jQuery 数据表 "No Data Available in Table"

android - 更新到 Android Jelly Beans 后重复的动画

jquery-mobile - Jquery Mobile 在输入文本上粘贴事件

javascript - 是否可以为颜色选择创建一个 jQuery 移动范围 slider ,带有标签、阶梯边框和阶梯背景?

html - 是否可以使用 href 链接显示无?

javascript - 独立对父/子元素执行操作

javascript - 使用 jquery 从 select 中识别选项