});
$j("#" + this.opts.selectId).append(proOPts);
//初始化chosen
$j("#" + this.opts.selectId).chosen({
allow_single_deselect: true, //是否允许取消选择
placeholder_text_multiple: this.opts.placeholdertxt, //多选框没有选中任何值的时候 显示的文字
no_results_text: this.opts.noresulttxt,//无搜索结果时显示的文本
search_contains: true//是否支持模糊搜索
});
};
/*对象初始化方法*/
chosenTool.prototype.chosenInit = function () {
this.selectInfoInit();
};
//私有方法,检测参数是否合法
chosenTool.prototype.isValid = function () {
return !this.options || (this.options && typeof this.options === "object") ? true : false;
};
//数据同步
chosenTool.prototype.chose_get_init = function () {
var selectId = this.opts.selectId;
$j("#" + this.opts.selectId).chosen().change(
function () {
$j("#" + selectId).trigger("liszt:updated");//更新下拉框
});
};
//单选select value获取
chosenTool.prototype.chose_get_value = function () {
var selectVal = $j("#" + this.opts.selectId).val();
$j("." + this.opts.hidClassName).val(selectVal);
};
//单选select value获取
chosenTool.prototype.chose_mult_set_init = function () {
var values = $j("." + this.opts.hidClassName).val();
if (values && values.indexOf(',') > 0) {
var arr = values.split(',');
var length = arr.length;
var value = '';
for (i = 0; i < length; i++) {
value = arr[i];
$j("#" + this.opts.selectId + " [value='" + value + "']").attr('selected', 'selected');
}
} else {
$j("#" + this.opts.selectId + " [value='" + values + "']").attr('selected', 'selected');
}
$j("#" + this.opts.selectId).trigger("liszt:updated");
};
//select text获取,多选时请注意
chosenTool.prototype.chose_get_text = function () {
return $j("#" + this.opts.selectId + " option:selected").text();
};
})(jQuery);
以上所述是小编给大家介绍的jQuery Chosen通用初始化,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!










