Skip to content

Instantly share code, notes, and snippets.

@ponsuke0531
Last active April 11, 2019 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ponsuke0531/f69c0f59b9fe66a4e63cd894194183f6 to your computer and use it in GitHub Desktop.
Save ponsuke0531/f69c0f59b9fe66a4e63cd894194183f6 to your computer and use it in GitHub Desktop.
スクロールできるダイアログでbootstrap-selectを使ったらリストが画面からはみ出して選択できなくなった時の対応方法 ref: https://qiita.com/ponsuke0531/items/6e055428c33f7c644255
<省略>
setSize: function () {
<省略>
} else if (this.options.size && this.options.size != 'auto' && menu.find('li' + notDisabled).length > this.options.size) {
var optIndex = this.$lis.not('.divider' + notDisabled).find(' > *').slice(0, this.options.size).last().parent().index();
var divLength = this.$lis.slice(0, optIndex + 1).filter('.divider').length;
menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding;
if (that.options.dropupAuto) {
//noinspection JSUnusedAssignment
this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight < menu.height()));
}
menu.css({'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + 'px', 'overflow': 'hidden'});
menuInner.css({'max-height': menuHeight - menuPadding + 'px', 'overflow-y': 'auto'});
}
<省略>
<他は変更ないので省略>
<select id="dialogSelect" class="selectpicker"></select>
<他は変更ないので省略>
<他は変更ないので省略>
/**
* ダイアログのスタイル.
*/
.modal-content {
width: 300px;
/* height: 120px;
overflow-y: scroll;*/
}
<他は変更ないので省略>
/**
* ドロップダウンを作る.
*/
function createDropdown() {
var options = {
size: 3
};
$('#dialogSelect').selectpicker(options);
}
<他は変更ないので省略>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment