zoukankan      html  css  js  c++  java
  • jquery mobiscroll 滑动、滚动

    mobiscroll : 滑动选择

    2.13.2版本免费,官网(mobiscroll.com)收费

    先从官方下载2.13.2体验版下来,查看例子结合官方API学习( http://docs.mobiscroll.com/2-13-2 )

    另外官方还有在线例子:

    http://demo.mobiscroll.com/mobile/datetime/date/#display=modal&theme=mobiscroll&lang=en&language=zh

    http://demo.mobiscroll.com/select/countrypicker/#language=zh&display=modal

    .net 可以在程序包管理控制台输入安装:Install-Package Mobiscroll

    下载完成后,保留mobiscroll-2.13.2.full.min.css,mobiscroll-2.13.2.full.min.js , 其它的css、js可删除

    .net视图引擎可直接渲染mobiscroll控件

    [csharp] view plaincopyprint?
     
    1. @using (Html.BeginForm())  
    2. {  
    3.     @Html.LabelFor(m => m.Name)  
    4.     @Html.TextBoxFor(m => m.Name)  
    5.     <br />  
    6.     @Html.LabelFor(m => m.Birthday)  
    7.   
    8.     <!-- Generate a date scroller for the birthday model property-->  
    9.     @Html.Mobiscroll().DateFor(m => m.Birthday)  
    10.     <br />  
    11.     @Html.LabelFor(m => m.Gender)  
    12.   
    13.     <!-- create the selectlist used for the select scroller -->  
    14.     IEnumerable<SelectListItem> genders = new SelectList(new List<string>(){"male", "female"});  
    15.     @Html.Mobiscroll().SelectFor(m => m.Gender, genders)  
    16.     <br />  
    17.     @Html.LabelFor(m => m.FavoriteBook)  
    18.   
    19.     <!-- create the selectlist for the books grouped by author -->  
    20.     Dictionary<string, IEnumerable<SelectListItem>> books = new Dictionary<string, IEnumerable<SelectListItem>>();  
    21.     books.Add("Adams", new SelectList(new List<string>() {   
    22.         "The Hitchhiker's Guide to the Galaxy",   
    23.         "The Restaurant at the End of the Universe",   
    24.         "So Long, and Thanks for All the Fish",   
    25.         "Life, the Universe and Everything"   
    26.     }));  
    27.     books.Add("Asimov", new SelectList(new List<string>() {   
    28.         "I, Robot",   
    29.         "The Caves of Steel",   
    30.         "Foundation"   
    31.     }));  
    32.     books.Add("Herbert", new SelectList(new List<string>() {   
    33.         "Dune",   
    34.         "God Emperor of Dune",   
    35.         "Dune Messiah",   
    36.         "Children of Dune"   
    37.     }));  
    38.     @Html.Mobiscroll().SelectFor(m => m.FavoriteBook, books)  
    39.     <br />  
    40.     <button type="submit">Send</button>  
    41. }  
    42.        


    详情:http://docs.mobiscroll.com/2-14-3/mvc-helpers

    以下是本人看了一下API后随意写的几个例子,其实用select去做会更好,此处只是演示,就随便啦!

    自定义年月(去掉年月日的"日"滚轮布局):

    [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    1. @{  
    2.     ViewBag.Title = "taste mobiscroll";  
    3. }  
    4. @section styles{  
    5. <link href="~/Content/mobiscroll-2.13.2.full.min.css" rel="stylesheet" />  
    6. <style>  
    7. </style>  
    8. }  
    9. <div class="container">  
    10.     <input id="date" />  
    11. </div>  
    12.   
    13. @section scripts{  
    14. <script src="~/Scripts/jquery-1.8.2.min.js"></script>  
    15. <script src="~/Scripts/mobiscroll-2.13.2.full.min.js"></script>     
    16. <script>  
    17. $(function () {  
    18.     $("#date").mobiscroll().date({  
    19.         theme: "android-ics light",  
    20.         lang: "zh",  
    21.         cancelText: null,  
    22.         dateFormat: 'yy/mm', //返回结果格式化为年月格式  
    23.         // wheels:[], 设置此属性可以只显示年月,此处演示,就用下面的onBeforeShow方法,另外也可以用treelist去实现  
    24.         onBeforeShow: function (inst) { inst.settings.wheels[0].length>2?inst.settings.wheels[0].pop():null; }, //弹掉“日”滚轮  
    25.         headerText: function (valueText) { //自定义弹出框头部格式  
    26.             array = valueText.split('/');  
    27.             return array[0] + "年" + array[1] + "月";  
    28.         }  
    29.     });  
    30. })   
    31. </script>  
    32. }  

    效果如下图:

    treelist 示例一:

    [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    1. <style>  
    2. .mbsc-android-holo .dwv { text-align:left;text-indent:.8em; }  
    3. </style>  
    4.   
    5. <ul id="treelist">  
    6.     <li>普通班</li><li>VIP班</li><li>特色班</li><li>至尊班</li><li>女子特训班</li>  
    7. </ul>  
    8.   
    9. <script>  
    10. $(function () {  
    11.     $("#treelist").mobiscroll().treelist({  
    12.         theme: "android-ics light",  
    13.         lang: "zh",  
    14.         defaultValue: [Math.floor($('#treelist li').length/2)],  
    15.         cancelText: null,  
    16.         headerText: function (valueText) { return "选择班级"; }  
    17.     });  
    18. })   
    19. </script>  


    效果如下图:

    treelist 示例二:

    [csharp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
     
    1. <style>  
    2. .mbsc-android-holo .dwv { text-align:left;text-indent:.8em; }  
    3. </style>  
    4.   
    5. <ul id="treelist">  
    6.     <li>  
    7.         <span>奥迪</span>  
    8.         <ul>  
    9.             <li>奥迪A3</li>  
    10.             <li>奥迪A4L</li>  
    11.             <li>奥迪A6L</li>  
    12.             <li>奥迪Q3</li>  
    13.             <li>奥迪Q5</li>  
    14.             <li>奥迪A4</li>  
    15.             <li>奥迪A6</li>  
    16.             <li>奥迪A1</li>  
    17.             <li>奥迪A3(进口)</li>  
    18.         </ul>  
    19.     </li>  
    20.     <li>  
    21.         <span>宝马</span>  
    22.         <ul>  
    23.             <li>宝马X1</li>  
    24.             <li>宝马i3</li>  
    25.             <li>宝马1系</li>  
    26.             <li>宝马3系</li>  
    27.             <li>宝马5系</li>  
    28.         </ul>  
    29.     </li>  
    30.     <li>  
    31.         <span>奔驰</span>  
    32.         <ul>  
    33.             <li>奔驰A级</li>  
    34.             <li>奔驰C级</li>  
    35.             <li>奔驰E级</li>  
    36.             <li>奔驰S级</li>  
    37.             <li>奔驰GLK级</li>  
    38.             <li>奔驰CLA级</li>  
    39.             <li>奔驰CLS级</li>  
    40.         </ul>  
    41.     </li>  
    42. </ul>  
    43.   
    44. <script>  
    45. $(function () {  
    46.     var i = Math.floor($('#treelist>li').length / 2),  
    47.         j = Math.floor($('#treelist>li').eq(i).find('ul li').length / 2);  
    48.     $("#treelist").mobiscroll().treelist({  
    49.         theme: "android-ics light",  
    50.         lang: "zh",  
    51.         defaultValue: [i,j],  
    52.         cancelText: null,  
    53.         placeholder: '选择车型',  
    54.         headerText: function (valueText) { return "选择车型"; },  
    55.         formatResult: function (array) { //返回自定义格式结果  
    56.             return $('#treelist>li').eq(array[0]).children('span').text() +' '+ $('#treelist>li').eq(array[0]).find('ul li').eq(array[1]).text().trim(' ');  
    57.         }  
    58.     });  
    59. })   
    60. </script>  


    效果如图:

  • 相关阅读:
    在传统软件公司十年深恶痛绝的感受
    前端 100 问:能搞懂80%的请把简历给我
    中专毕业的他,是如何逆袭为 360 资深程序员?
    别再参加领导力培训课程了,这本领导力提升书籍推荐给你
    企业管理书籍推荐,读完这个系列的书就是上完了整个MBA
    如何做好人才管理?人才管理书籍推荐
    如何管理好员工?你可能需要看看这本人员工管理方面的经典书籍
    领导与管理的区别和异同:什么是领导?什么是管理?
    一名优秀的HR需要具备哪些素质与能力?
    销售书籍推荐:做销售你究竟该看什么书?
  • 原文地址:https://www.cnblogs.com/Look_Sun/p/4482103.html
Copyright © 2011-2022 走看看