jQuery MiniUI

标题: checkboxList取值问题 [打印本页]

作者: tizzyg    时间: 2017-3-9 10:20:58     标题: checkboxList取值问题

checkboxList有一个valuechanged事件,是否有办法获取这个事件触发之前checkboxList的值呢??

作者: jialiang    时间: 2017-3-9 11:30:45

本帖最后由 jialiang 于 2017-3-9 12:06 编辑

你可以用onbeforeselect事件来获取改变值之前的值(这里是代码,复制粘贴就可使用):
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <title></title>
  5.         <script src="http://www.miniui.com/scripts/boot.js" type="text/javascript"></script>
  6. </head>
  7. <body>
  8.     <div id="demo1" class="mini-checkboxlist" textField="text" valueField="id" value="cn,usa"
  9.         repeatItems="3" repeatLayout="table" onvaluechanged="change()" onbeforeselect="alert(this.getValue())">
  10.         
  11.         </div>
  12.         
  13.         <script>
  14.                 mini.parse();
  15.                 var s = [
  16.              { "id": "usa", "text": "美国" },
  17.                  { "id": "cn", "text": "中国" },
  18.                  { "id": "jp", "text": "日本", enabled: false },
  19.                  { "id": "de", "text": "德国" },
  20.                  { "id": "fr", "text": "法国" },
  21.                  { "id": "ca", "text": "加拿大" },
  22.                  { "id": "at", "text": "奥地利" },
  23.                  { "id": "ch", "text": "瑞士" }
  24.            ];

  25.                 var cblist1 = mini.get("demo1");
  26.                 cblist1.loadData(s);
  27.                 function change() {
  28.                         alert(cblist1.getValue());
  29.                 }
  30.         </script>
  31. </body>
  32. </html>
复制代码







欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2