我正在使用Daniel Farrell的bootstrap Combobox
https://github.com/danielfarrell/bootstrap-combobox
我想在用户点击文本框时打开选择框,(然后如果他们在文本框中键入,则会照常过滤)
我试图在构造函数上添加一些额外的代码:
var Combobox = function (element, options) {
this.options = $.extend({}, $.fn.combobox.defaults, options);
this.$source = $(element);
this.$container = this.setup();
this.$element = this.$container.find('input[type=text]');
this.$target = this.$container.find('input[type=hidden]');
this.$button = this.$container.find('.dropdown-toggle');
this.$menu = $(this.options.menu).appendTo('body');
this.template = this.options.template || this.template
this.matcher = this.options.matcher || this.matcher;
this.sorter = this.options.sorter || this.sorter;
this.highlighter = this.options.highlighter || this.highlighter;
this.shown = false;
this.selected = false;
this.refresh();
this.transferAttributes();
this.listen();
if (options.opener!= undefined) {
this.opener(options.opener); //my extra "option"
}
};
Combobox.prototype = {
opener: function (element) {
$(element).click(function () {
//What to write here
}
}
但是当我点击文本框时,我似乎无法获得正确的命令来打开选择选项。
答案 0 :(得分:0)
替换"你的textare id"使用您的textarea选择器和"您的选择下拉菜单"使用您的选择下拉选择器并检查
$('input').keyup(function(){
var getScore = Number($("#score").val());
var getBonus = Number($("#bonus").val());
var getAddToScore = Number($("#addToScore").val());
var getAddToBonus = Number($("#addToBonus").val());
CalculateBonus = Math.floor((getScore - 10) / 2);
$("#bonus").val(CalculateBonus);
var addToTheScore = getScore + getAddToScore;
var addToTheBonus = getBonus + getAddToBonus;
$("#score").val(addToTheScore);
$("#bonus").val(addToTheBonus);
})