zoukankan      html  css  js  c++  java
  • easyui combobox 实时刷新

    使用场景:

    A页面以及B页面,A页面有个下拉框,数据是从B页面存在的数据库中获取得到的;现将B页面的数据删除掉,但是在A页面再次点开下拉框时,依旧看到了刚才删除的那条数据;

    期望:当B页面已何种方式改变数据库的值时,A页面的下拉框均能实时刷新。

    起初不能实现的方法:

    1 <td align="right">分类:</td>
    2                 <td align="right"><input id="s_typeid"
    3                                           data-options="valueField:'typeid',textField:'typename',panelHeight:'150px';url:'/hotspot/questionstype/typelist'"
    4                                           style=" 150px;" class="easyui-combobox"></td>
    1 <script>
    2    $(function(){
    3         $('#s_typeid').combobox({ 
    4              url:'/hotspot/questionstype/typelist?t=' + new Date().getTime(),
    5              valueField:'typeid',   
    6              textField:'typename'  
    7     });
    8 </script>

    直接在页面加载完成后,就将下拉框的数据获取到,并赋值给它,于是就出现文章开头的那个问题,后来解决办法:

    将HTML中的url属性(第一段代码的绿色部分)去掉,然后使用combobox的onShowPanel方法便可

    1   $('#s_typeid').combobox({ 
    2             onShowPanel : function(){
    3                 var s=$(this).combobox('getData');
    4                 $(this).combobox('options').url= '/hotspot/questionstype/typelist?t=' + new Date().getTime();
    5                     $(this).combobox('reload');
    6             }
    7         });  
  • 相关阅读:
    修改sql表操作大全
    Asp.NET自定义DataGrid控件
    jQuery LigerUI 插件介绍及使用之ligerGrid
    jQuery LigerUI API预览版发布
    jQuery LigerUI 初次发布&一睹为快(提供Demo下载)
    jQuery LigerUI 插件介绍及使用之ligerDrag和ligerResizable
    nginx 日志
    nginx 正向代理
    排序
    nginx 静态资源优化
  • 原文地址:https://www.cnblogs.com/zhengyeye/p/9014191.html
Copyright © 2011-2022 走看看