简体   繁体   English

如何从数组加载数据列表中的更多数据

[英]How to load more data in datalist from array

I have an array of data which i have to show in datalist. 我有一个数据数组,必须在数据列表中显示。 I want to load only limited data first and then load another limited data as scroll goes down. 我想先只加载有限的数据,然后在滚动下降时加载另一个有限的数据。 All this work i have to done inside datalist ie i need to put that scroll inside datalist and then when scroll goes down to the end of datalist screen , more data will be come from array. 我必须在数据列表中完成所有这些工作,即我需要将滚动条放在数据列表中,然后当滚动下降到数据列表屏幕的末尾时,更多数据将来自数组。

I am using meteor so i need to return that array on client side using helpers. 我正在使用流星,所以我需要使用助手在客户端返回该数组。 My code is : 我的代码是:

This is my helper. 这是我的助手。 Here a is array which will return on html(client side). 这里是一个数组,它将在html(客户端)上返回。

Template.mytemplate.helpers({
  // Here will be helper for displaying data in client side//
  searched_val:function(){
    var a= SessionStore.get("myvalue");
    // console.log(a);
    return a;
  }
  }
});

My html code is (client side code) : 我的html代码是(客户端代码):

<div class="form-group row ">
            <div class="dropdown col-xs-12">
              <input list="d1" id="search" name="d1" class="form-control input-xs" placeholder="Search by">
                <datalist id="d1" style="overflow-y:auto">
                  {{#each searched_val}}
                <option class="form-control" value="{{this}}"> {{this}} </option>
                 {{/each}}
               </datalist>
            </div>
        </div>

Now , How can i do it. 现在,我该怎么做。 Is there any jquery,Javascript code for it? 是否有任何jquery,Javascript代码?

I also have seen "Jquery load more data on scroll" here but it doesn't work for me as that was used for whole page/window but i need to do it for only datalist and within datalist. 我在这里也看到过“ jQuery在滚动上加载更多数据”,但是它对我不起作用,因为它用于整个页面/窗口,但是我只需要对datalist和datalist进行处理。 Here is the link " jQuery load more data on scroll " But it didn't work for me. 这是链接“ jQuery在滚动条上加载更多数据 ”,但对我而言不起作用。

Thanks in Advance 提前致谢

What should you do... 你该怎么办...

1) First you subscribe the limited array from your desired collection. 1)首先,您从所需集合中订购有限阵列。

2) Just return the <collection>.find() to the helper. 2)只需将<collection>.find()返回给助手。

3) Then add a scroll event listener through which you'll check if the current scroll position has reached the last limit of the page then you'll subscribe more items. 3)然后添加滚动事件侦听器,通过它可以检查当前滚动位置是否已达到页面的最后限制,然后您将预订更多项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM