javascript - <Select> widget with infinite scroll dropdown -


at page have 20 common html select widgets. example:

<select>     <option>1</option>     ...     <option>3000</option> </select>  

that have 3000 or more elements in each one. have decided convert them ajax selects load items dynamically when scrolling.

how can ??

i have provided set of working example of combo-box using jquery ui selectmenu. have used basic json source ajax request, please work on part yourself.

$(".ajax-combo").selectmenu({    "width": "100px",  });  $(".ajax-combo").selectmenu("menuwidget").addclass("make-scrolling");  $(".ajax-combo").selectmenu("menuwidget").scroll(function(e) {    if (e.currenttarget.scrollheight - 10 < e.currenttarget.scrolltop + $(e.currenttarget).height()) {      var curtar = e.currenttarget;      var lasttop = curtar.scrolltop;      $.getjson("http://echo.jsontest.com/10/test/20/rest/30/best/40/vest/50/fest", function(data) {        $.each(data, function(key, val) {          $(".ajax-combo").append("<option value='" + key + "'>" + val + "</option>");        });        $(".ajax-combo").selectmenu("refresh");        curtar.scrolltop = lasttop;      });    }  });
.make-scrolling {    overflow-y: scroll;    height: 150px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>    <select class="ajax-combo">    <option>1</option>    <option>2</option>    <option>3</option>    <option>1</option>    <option>2</option>    <option>3</option>    <option>1</option>    <option>2</option>    <option>3</option>    <option>1</option>    <option>2</option>    <option>3</option>  </select>


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -