I am generating a select option box dynamically. There can be any number of options. When the user scrolls down to the end of the box, I need to trigger an event, (where I will call the server and populate the select with more options). Its like creating a pagination, but in dropdown box.
Can anybody tell me how can this be done.
So the only thing I need is to trigger an event, when user scrolls to the end of the dropdown. Thats all
<select style="height: 30px;line-height:30px;" class="scroll">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
Please don't worry about how I am gonna populate the select box with option, as I am using meteorJs, that I will achieve it easily.
The only requirement is to fire an event.
There is no way to detect scrolling on an actual
select
element, so this isn't possible as asked. But you can try creating a custom select-box looking control which is just a scrolling div and apply the feature to it.UPDATE
DEMO HERE
For the
chosen-jquery-plugin
you make events listen as below:This is how the
html
will be generated fromchosen
plugin for your select box:Write a style for
.chosen-drop
and modify your styles as below and removeinline
style fromselect
Your JS would be