php - 使用 select2 时,选择框自动隐藏
问题描述
<div class="col-12 col-sm-12 col-md-5 col-lg-5 col-xl-5" id="old_customer" style="display: block;>
<label for="customersID" class="control-label">Customer </label>
<select name="customersID" id="customersID" onchange="getCustomersDue()" >
<option value="">Select Customer </option>
<?php
foreach($customers as $p)
{
$selected = ($p['customersID'] == $this->input->post('customersID')) ? ' selected="selected"' : "";
echo '<option value="'.$p['customersID'].'" '.$selected.'>'.$p['name']."-".$p['mobile'].'</option>';
}
?>
</select>
$("#customersID").select2();
我正在从数据库中获取所有客户,并使用 select2 搜索并选择项目。但是当我选择某些东西时,整个 div 会隐藏,我无法重新选择任何东西。但该值仍保留在页面中。任何解决方案都会有所帮助。谢谢。
解决方案
您需要使用下面的代码进行 onchange。删除此代码onchange="getCustomersDue()"
$('#customersID').on('select2:select', function(e) {
console.log('Selecting: ' , e.params.args.data);
});
读这个
推荐阅读
- azure-api-management - 无法使用 Azure API 管理液体模板解析肥皂响应
- angular - 添加新的角度组件 npm 安装和导入的步骤是什么?
- python - 餐厅菜单和收据的最佳解决方案
- wpf - 对话框出现在其他窗口后面
- json - Postgres 通过复制脚本导出不喜欢导入时带引号的 json
- powerpoint - 在 Powerpoint 视图中替换字体不会替换字体
- node.js - Microsoft Graph API 委托权限 - 访问令牌 NodeJs
- protractor - Protractor & Angular 8:在 Angular 应用程序运行之前设置 localStorage?
- javascript - 在数组中查找对象,以查找 id 匹配子字符串的对象
- java - 如何在扫描空格并在每个空格之后插入额外空格时将 RandomAccessFile 打印到 .txt 文件