javascript - Select2 + custom scrollbar - Stack Overflow

I'm trying to connect some custom scrollbars with Select2 4.0. I found some old topics here on sta

I'm trying to connect some custom scrollbars with Select2 4.0. I found some old topics here on stackoverflow, but the solutions (with select2 3.4 i.e.) seems to be outdated.

I tried: jquery.scrollpane and jquery.nicescroll. Both scrollbars don't work with Select2 4.0. Or maybe I did something wrong?

scrollpane solution (when used, "No results found" error occures)

$(function() {
	$('.select2-with-scroll').jScrollPane();
	
	$w.on('resize', function() {
		$('.select2-with-scroll').jScrollPane();
	});
}); 
<select class="select2-with-scroll">
  <option value=""></option>
  <option value="50">50</option>
  <option value="55">55</option>
  <option value="60">60</option>
  <option value="65">65</option>
  <option value="70">70</option>
  <option value="75">75</option>
  <option value="80">80</option>
  <option value="85">85</option>
  <option value="90">90</option>
  <option value="95">95</option>
  <option value="100">100</option>
</select>

I'm trying to connect some custom scrollbars with Select2 4.0. I found some old topics here on stackoverflow, but the solutions (with select2 3.4 i.e.) seems to be outdated.

I tried: jquery.scrollpane and jquery.nicescroll. Both scrollbars don't work with Select2 4.0. Or maybe I did something wrong?

scrollpane solution (when used, "No results found" error occures)

$(function() {
	$('.select2-with-scroll').jScrollPane();
	
	$w.on('resize', function() {
		$('.select2-with-scroll').jScrollPane();
	});
}); 
<select class="select2-with-scroll">
  <option value=""></option>
  <option value="50">50</option>
  <option value="55">55</option>
  <option value="60">60</option>
  <option value="65">65</option>
  <option value="70">70</option>
  <option value="75">75</option>
  <option value="80">80</option>
  <option value="85">85</option>
  <option value="90">90</option>
  <option value="95">95</option>
  <option value="100">100</option>
</select>

nicescroll solution (absolutely no effects, HTML as above)

$(document).ready(
  function() { 
    $("select2-with-scroll").niceScroll();
  }
);

Is there any other custom scrollbars which I can use with Select2 4.0? Or maybe it's possible to connect nicescroll or scrollpane with Select2? Any help will be appreciated.

Share Improve this question asked Nov 11, 2015 at 12:49 JohnnyXecutorJohnnyXecutor 531 silver badge7 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

With select2 v4.0 + nicescroll v3.6.6 try to make something like this

$('select').select2()
.on("select2:open", function () {
    $('.select2-results__options').niceScroll();
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744699100a4588671.html

相关推荐

  • javascript - Select2 + custom scrollbar - Stack Overflow

    I'm trying to connect some custom scrollbars with Select2 4.0. I found some old topics here on sta

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>