JQuery: Infinite input select

2019-06-07 10:24发布

I would like to know if it's possible to create an infinite input select using JQuery: In other words, I want to load x options in my select and load more once the user reach the bottom.

Thanks

5条回答
可以哭但决不认输i
2楼-- · 2019-06-07 11:14

There are no events you can use to detect when they have reached the bottom of a select, you could add an option at the bottom with something like "Load More" that would dynamically add new options to the list. You could even add an onmouseover event to this bottom option so that they don't have to click to load the new options.

查看更多
Evening l夕情丶
3楼-- · 2019-06-07 11:23

I don't think it's possible just use select, maybe you could simulate a select use div or other things by yourself.

查看更多
一夜七次
4楼-- · 2019-06-07 11:25

There is no way to detect scrolling on an actual select box, so this isn't possible as asked. You can, however, create a custom select-box looking control which is just a scrolling div and apply the feature to it.

查看更多
做个烂人
5楼-- · 2019-06-07 11:26

I think your best option would be to create a pseudo-select control (perhaps a DIV with CSS overflow, or a scrolling multi-line textbox?).

I believe the effect you want would be similar to the scrolling lists that you can see here (choose a train jouney first):

http://tickets.eastcoast.co.uk/ec/en/JourneyPlanning/MixingDeck

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-06-07 11:27
$('#selectElm').change(function()
{
   var selIndex = $('#selectElm').attr("selectedIndex");
   var numItems = $(this).children('option').length);
   if (selIndex == numItems - 1) //then we are at the bottom item
   {
      //add new items here
   } 
});

Caveat: This only works if they select the bottom item ... not just mousing over it.

查看更多
登录 后发表回答