l***@163.com
l***@163.com
  • 发布:2017-06-16 16:15
  • 更新:2017-06-17 11:55
  • 阅读:1504

索引列表范例,数据绑定(html拼接) 后,搜索数据异常(搜索关键字 "1")

分类:MUI

<!DOCTYPE html>
<html>

<head>  
    <meta charset="utf-8">  
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
    <title></title>  
    <link href="../css/mui.min.css" rel="stylesheet" />  
    <link href="../css/mui.indexedlist.css" rel="stylesheet" />  
    <style>  
        html,  
        body {  
            height: 100%;  
            overflow: hidden;  
        }  
        .mui-bar {  
            -webkit-box-shadow: none;  
            box-shadow: none;  
        }  
    </style>  
</head>  

<body>  
    <header class="mui-bar mui-bar-nav">  
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>  
        <h1 class="mui-title">indexed list(索引列表)</h1>  
    </header>  
    <div class="mui-content">  
        <div id='list' class="mui-indexed-list">  
            <div class="mui-indexed-list-search mui-input-row mui-search">  
                <input type="search" class="mui-input-clear mui-indexed-list-search-input" placeholder="搜索机场">  
            </div>  
            <div class="mui-indexed-list-bar">  
                <a>A</a>  
                <a>B</a>  
                <a>C</a>  
                <a>D</a>  
                <a>E</a>  
                <a>F</a>  
                <a>G</a>  
                <a>H</a>  
                <a>I</a>  
                <a>J</a>  
                <a>K</a>  
                <a>L</a>  
                <a>M</a>  
                <a>N</a>  
                <a>O</a>  
                <a>P</a>  
                <a>Q</a>  
                <a>R</a>  
                <a>S</a>  
                <a>T</a>  
                <a>U</a>  
                <a>V</a>  
                <a>W</a>  
                <a>X</a>  
                <a>Y</a>  
                <a>Z</a>  
            </div>  
            <div class="mui-indexed-list-alert"></div>  
            <div class="mui-indexed-list-inner">  
                <div class="mui-indexed-list-empty-alert">没有数据</div>  
                <ul class="mui-table-view">  
                    <li data-group="A" class="mui-table-view-divider mui-indexed-list-group">A</li>  
                    <li data-value="22-33机场" data-tags="22-33" class="mui-table-view-cell mui-indexed-list-item">22-33机场</li>  
                    <li data-value="12-34机场" data-tags="12-34" class="mui-table-view-cell mui-indexed-list-item">12-34机场</li>  
                    <li data-value="34-56机场" data-tags="34-56" class="mui-table-view-cell mui-indexed-list-item">34-56机场</li>  
                    <li id="s"></li>  

                </ul>  
            </div>  
        </div>  
    </div>  
    <script src="../js/mui.min.js"></script>  
    <script src="../js/mui.indexedlist.js"></script>  
    <script type="text/javascript" charset="utf-8">  
        mui.init();  
        mui.ready(function() {  
        var header = document.querySelector('header.mui-bar');  
            var list = document.getElementById('list');  
            //calc hieght  
            document.getElementById("s").innerHTML += "<li id=aaa data-value=\"22-33机场\" data-tags=\"22-33\" class=\"mui-table-view-cell mui-indexed-list-item\" >22-33机场a</li>";  
            document.getElementById("s").innerHTML += "<li id=bbb data-value=\"12-34机场\" data-tags=\"12-34\" class=\"mui-table-view-cell mui-indexed-list-item\" >12-34机场b</li>";  
            document.getElementById("s").innerHTML += "<li id=ccc data-value=\"34-56机场\" data-tags=\"34-56\" class=\"mui-table-view-cell mui-indexed-list-item\" >34-56机场c</li>";                                          
            list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';  
            //create  
            window.indexedList = new mui.IndexedList(list);  

// mui("#list").indexedList().findElements();
});
</script>
</body>

</html>

2017-06-16 16:15 负责人:无 分享
已邀请:
l***@163.com

l***@163.com (作者) - 刷刷刷

已找到http://ask.dcloud.net.cn/article/509 之前发的帖子相关解决方案!!

l***@163.com

l***@163.com (作者) - 刷刷刷

经过测试失败的:
动态数据加载完毕后 加入:
list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';
//create
window.indexedList = new mui.IndexedList(list);

或者把
window.indexedList = new mui.IndexedList(list);
改成:
mui("#list").indexedList().findElements();

均搜索异常!!

l***@163.com

l***@163.com (作者) - 刷刷刷

已自行解决,数据绑定位置问题!!

该问题目前已经被锁定, 无法添加新回复