• bootstrap-select 使用笔记 设置选中值及手动刷新


    直接笔记: 

      1、页面刚加载完填充select选项数据时,需要手动刷新一下组件,否则没有选项值。(组件初始化时,li 与 option 分离的,需要刷新一下(据说))

      

     $.post('/cpms/todo/getProjectList', data).done(function(result) {
        if(typeof(result) == "string"){
          result = JSON.parse(result.data);
        }
        if(result.data.rows){
          viewModel._helper.projectCodes(result.data.rows); 
          $('.selectpicker').selectpicker('refresh');
        }
        
      }).fail(function (err) {
        return '';
      })
    

      2、组件选中值更改时,即为组件设置选中值时,需要设置一下 val 

    util.backend('cpmsapi/getOrderListForMobile', {ledgerId: keyword}).done(function (result) {
          if (result.ResultCode && result.ResultData.total>0) {
           $('.selectpicker').selectpicker('val',result.ResultData.rows[0].PROJECT_CODE);
           // $('.selectpicker').selectpicker('refresh');
            
          } else {
            viewModel.data(jsonNull)  
            viewModel._helper.failedLoading(true)
            viewModel._helper.failedLoadingMessage('未查询到结果')
          }
    
        }).fail(function (err) {
          viewModel._helper.failedLoading(true)
          viewModel._helper.failedLoadingMessage('查询任务时发生错误')
          console.log(err)
        }).always(function () {
          viewModel._helper.loading(false)
        })
      }
    

      

  • 相关阅读:
    Javascript 生成全局唯一标识符 (GUID,UUID)
    nginx 与location语法详解
    nginx的安装与使用
    Linux上python3的安装和使用
    Linux上Redis安装和简单操作
    MySQL + centos +主从复制
    web服务基础
    linux系统基础优化及高级操作命令
    vim编辑
    Linux的基本命令
  • 原文地址:https://www.cnblogs.com/yeyuchangfeng/p/6237709.html
Copyright © 2020-2023  润新知