• Html5+Mui前端框架,开发记录(四):下拉菜单绑定数据、搜索、时间控件


    1.下拉菜单绑定数据,选择后回传值

    1)html:

    1     <div class="mui-input-row">
    2     <label>xxx:</label>
    3     <input id='zxyy' type="text" class="mui-input-clear mui-input" placeholder="请选择xxx">
    4     </div>

    2)js:

     1           document.getElementById("zxyy").addEventListener('tap', function() {
     2                 Selectzxyy();
     3             });
     4 
     5             function Selectzxyy() {
     6                 var specModel = new mui.PopPicker(); //初始化 picker
     7                 mui.ajax({
     8                     url: getAddress() + '/api/Hospital/get?jsoncallback=?',
     9                     data: {},
    10                     async: true,
    11                     dataType: 'json',
    12                     crossDomain: true, //强制使用5+跨域  
    13                     type: 'get',
    14                     timeout: 10000,
    15                     success: function(data) {
    16                         if (data.length > 0) {
    17                             var item = [];
    18                             for (var i = 0; i < data.length; i++) {
    19                                 arrStr = {
    20                                     text: data[i].HospitalName,
    21                                     value: data[i].Id
    22                                 };
    23                                 item.push(arrStr);
    24                             }
    25                             specModel.setData(item);
    26                             specModel.show(function(item) {
    27 28 var specModelName = item[0].text; 29 var t = document.getElementById('zxyy'); 30 t.value = specModelName; 31 t.tabIndex = item[0].value; 32 var specModelValue = item[0].Id; 33 }); 34 } 35 }, 36 error: function(xhr, type, errorThrown) {} 37 }); 38 }

    2.时间控件

    1)html:

    1                 <div class="mui-input-row">
    2                             <label>日期:</label>
    3                             <input type="datetime" id="startdate" placeholder="请选择时间" onclick="dtime()">
    4                         </div>

    2)js:

    1 <link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
    2 <script src="js/mui.picker.min.js"></script>        
     1     function dtime() {
     2                 var Date = new mui.DtPicker({
     3                     type: 'date'
     4                 });
     5                 var endDate = "";
     6                 Date.show(function(item) {
     7                     //这里你可以用console 看看回调函数中的item的值                          
     8                     endDate = item;
     9                     var s = document.getElementById('startdate');
    10                     s.value = endDate.toString();
    11                 });
    12             }

    3.搜索

    1)html:

    1                  <div class="mui-indexed-list-search mui-input-row mui-search">
    2                 
    3                      <input type="search" id="searchInput" onkeyup="enterSearch(event)" class="mui-input-clear" placeholder="关键字">
    4                     </div>

    2)js:

    1 function enterSearch(event){
    2             if(event.keyCode == 13) {//用户点击回车的事件号为13
    3                 var keyword = document.getElementById('searchInput').value;                
    4         //createFragment(keyword);(自己的逻辑代码)
    5             }
    6         }
  • 相关阅读:
    我受不了了,可能拿不到毕业证了
    [My B.S paper draft]我的本科答辩论文草稿
    Memory Dog for Autodesk Maya
    Silent Hill 5 Bug
    AMPAS/ASC Common File Format LUT
    CUDAAccelerated LUT Converter for DI Workflow
    Forking AfterBurn into Maya
    nicEdit上传图片无法显示的问题
    用插值的方法进行直方图平滑
    一个新的做presentation的利器
  • 原文地址:https://www.cnblogs.com/bonnie-w/p/10750119.html
Copyright © 2020-2023  润新知