jQuery Moblie 学习(一)

1.jQTouch
jQTouch与jQuery Moblie十分相似,也是一个jQuery插件,同样也支持HTML页面标签驱动,实现移动设备视图切换效果。不同的是它是专为WebKit内核的浏览器打造的,可以借助该浏览器的专有功能对页面进行渲染;此外,开发时所需的代码量更少。如果开发的项目中,目标用户群都使用WebKit内核的浏览器,可以考虑此框架。

2.Sencha Touch
Sencha Touch是一套基于ExtJS开发的插件库。也是针对于WebKit内核的浏览器打造的,不同的是它的开发语言不是基于HTML标签,而是类似于客户端的MVC风格编写的JS代码,相对来说,学习周期较长。

看代码:

_Layout.cshtml

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">@*网站页面的自适应,宽度为驱动设备的宽度*@
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    @Styles.Render("~/Content/mobileCss", "~/Content/css")@*<link href="~/Content/jquery.mobile-1.4.2.css" rel="stylesheet" />*@
    @Scripts.Render("~/bundles/modernizr")@*<script src="~/Scripts/modernizr-2.6.2.js"></script>*@
    @*modernizr就是为HTML5而生的——它是一个检测浏览器对HTML5和CSS3特性支持的JS库,通过检测你的浏览器对html5/css3的支持情况,返回特定的样式名称,从而可以针对不同的浏览器写出不同的样式。*@
</head>
<body>
    @RenderBody()
    @Scripts.Render("~/bundles/jquery")@*<script src="~/Scripts/jquery-1.8.2.js"></script>*@
    <script>

        //该事件在ready()之前执行,因为mobileinit事件是在加载后马上触发,所以你需要在Jquery Mobile加载之前绑定你的事件处理函数,
        //必须放在jQuery和jQuery Moblie之间
        $(document).on("mobileinit", function () {
            $.mobile.ajaxEnabled = true;
        });
    </script>
    @Scripts.Render("~/bundles/jquerymobile")@*<script src="~/Scripts/jquery.mobile-1.4.2.js"></script>*@
    @RenderSection("scripts", required: false)
</body>
</html>

Index.cshtml

<section data-role="page" id="foo">
    <header data-role="header" data-theme="b" data-position="fixed" data-fullscreen="true">
        @*data-position="fixed" 让头部和尾部固定在浏览器顶部
        data-fullscreen="true" 不占位
        *@
        <h1>Page Title</h1>
    </header>
    <div role="main" class="ui-content">
        <p>Page content goes here.</p>
        <p><a href="#bar"  class="ui-btn ui-shadow ui-corner-all ui-btn-icon-notext ui-icon-delete ui-btn-inline" data-transition="slide">go to bar</a>@*跳转到id=”bar“页面*@
            <a href="#bar"  class="ui-btn ui-shadow ui-corner-all ui-btn-icon-notext ui-icon-delete ui-btn-inline" data-transition="slide">go to bar</a>

              <a href="#bar"  class="ui-btn ui-shadow ui-corner-all  ui-icon-delete ui-btn-inline ui-btn-icon-left" data-transition="slide" data-mini="true">go to bar</a>
        </p>
        @*    ui-btn :按钮样式
        ui-shadow:按钮加上阴影
         ui-corner-all:按钮圆角
        data-transition="slide": 跳转的页面效果
        ui-btn-icon-notext 让按钮没有文字
        ui-icon-delete  出现删除的图片
         ui-btn-inline 行内不占一行
        ui-btn-icon-left 让图标出现在文字的左边
        *@

            <div data-role="controlgroup" data-mini="true" data-type="horizontal">
                <a href="#" class="ui-btn ui-corner-all">no icon</a>
                     <a href="#" class="ui-btn ui-corner-all ui-icon-delete ui-btn-icon-left">left</a>
                <a href="#" class="ui-btn ui-corner-all ui-icon-delete ui-btn-icon-right">right</a>
            </div>
        @* data-role="controlgroup" 控件组
         data-type="horizontal" 控件排列方式
        *@
            <a href="#leftpanel3" class="ui-btn ui-shadow ui-corner-all ui-btn-inline ui-btn-mini">Overlay panel</a>

        <div data-role="collapsible">
            <h4>Heading</h4>
            <p>I‘m the collapsible content.By default I‘m closed,but you can click the header to open me.</p>
        </div>

        <ul data-role="listview" data-filter="true" data-filter-placeholder="请输入" data-inset="true">
            <li>
                <a href="#">Acura</a>
            </li>
            <li><a href="#">Audi</a></li>
            <li><a href="#">BMW</a></li>
            <li><a href="#">Cadillac</a></li>
            <li><a href="#">Ferrari</a></li>
        </ul>

        <div>

        </div>
    </div>
    <footer data-role="footer" data-theme="c" data-position="fixed">
        <div data-role="navbar" data-iconpos="left">
            <ul>
                <li><a href="#" class="ui-btn-active" data-icon="home">One</a></li>
                <li><a href="#" data-icon="gear">two</a></li>
                <li><a href="#" data-icon="back">Three</a></li>
            </ul>
        </div>
        @*
         data-role="navbar" 导航
           data-iconpos="left" 所有的导航图标都向左
        *@
    </footer>

    <div data-role="panel" id="leftpanel3" data-position="left" data-display="overlay" data-theme="a">

        <h3>Left Panel: Overlay</h3>
        <p>This panel is positioned on the left with the overlay display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
        <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
        <a href="#demo-links" data-rel="close" class="ui-btn ui-shadow ui-corner-all ui-btn-a ui-icon-delete ui-btn-icon-left ui-btn-inline">Close panel</a>

    </div><!-- /leftpanel3 -->

</section>

<!-- Start of second page -->
<section data-role="page" id="bar">

    <header data-role="header">
        <h1>Bar</h1>
    </header>
    <!-- /header -->

    <div role="main" class="ui-content">
        <p>I‘m the second in the source order so I‘m hidden when the page loads. I‘m just shown if a link that references my id is beeing clicked.</p>
        <p><a href="#foo" >Back to foo</a></p>@*跳转到id=”foo“页面*@

        <p><a href="#" data-rel="back" >Back to foo</a></p>@*跳转到id=”foo“页面*@

    </div>
    <!-- /content -->

    <footer data-role="footer">
        <h4>Page Footer</h4>
    </footer>
    <!-- /footer -->
</section>
<!-- /page -->

jQuery Moblie 学习(一)

时间: 2024-08-30 06:57:21

jQuery Moblie 学习(一)的相关文章

使用jquery moblie框架搭建一个手机版博客园

声明 本例仅供学习交流使用,不参与任何商业活动. 前言 本例结合我的前两篇博客 使用node.js爬取博客园首页的博客 和 使用原生node.js搭建HTTP服务器,支持MP4视频.图片传输,支持下载rar文件,使用jquery moblie框架搭建了一个简单的手机版博客园. 项目地址为手机版博客园http://blog.mdzz.tv:1011/,二维码和效果图如下,第一次加载可能有点慢. 服务器端输出日志如下: 源码我放在github上了,地址https://github.com/guass

jQuery插件学习笔记

最近在研究jQuery插件,插件编写的目的是给已经有的一系列方法或函数做一个封装,以便在其他地方重复使用,方便后期维护. JQuery除了提供一个简单.有效的方式进行管理元素以及脚本,它还还提供了例外一种机制:即给核心模块增加自己的方法和额外的功能.通过这种机制,Jquery允许我们自己创建属于我们自己的插件,提高我们在开发过程中的效率. 虽然在jQuery命名空间中,我们禁止使用了大量的javaScript函数名和变量名.但是仍然不可避免某些函数或变量名将于其他jQuery插件冲突,因此我们习

Jquery的学习(三)选择器

1.Jquery中最重要的就是选择器了. 学习要点: 1.简单选择器 2.进阶选择器 3.高级选择器 ①简单选择器. 最简单的也就是最常用的,最常用的一般也是最简单的. 在使用 jQuery 选择器时,我们首先必须使用"$()"函数来包装我们的 CSS 规则.而CSS 规则作为参数传递到 jQuery 对象内部后,再返回包含页面中对应元素的 jQuery 对象.随后,我们就可以对这个获取到的 DOM 节点进行行为操作了. #box { //使用 ID 选择器的 CSS 规则 color

Jquery的学习(二)基础核心

1.学习要点: 1.代码风格 2.加载模式 3.对象互换 一.代码风格: 在jQuery程序中,不管是页面元素的选择.内置的功能函数,都是美元符号"$"来起始的.而这个"$"就是jQuery当中最重要且独有的对象:jQuery对象,所以我们在页面元素选择或执行功能函数的时候可以这么写: $(function () {}); //执行一个匿名函数 $('#box'); //进行执行的ID元素选择 $('#box').css('color', 'red'); //执行功

第二十篇 jQuery 初步学习2

jQuery 初步学习2 前言: 老师这里啰嗦一下,因为考虑到一些同学,不太了解WEB前端这门语言.老师就简单的说一下,写前端,需要什么:一台笔记本.一个文本编辑器.就没啦!当然,写这门语言,我们要遵守它的规则,文本的后缀得是html,里面的编写格式当然也要遵守它的规则. 如果有同学没有好的编辑器,写代码很打脑壳,记不住单词等等,老师推荐一个编辑工具:WebStorm .老师用的就是这个来写的前端,版本用的是8.0.3,还是挺好用的. 上节课我们初步学习了jQuery,那么这节课,我们再深入了解

第十九篇 jQuery初步学习

jQuery 初步学习 jQuery可以理解为是一种脚本,需要到网上下载,它是一个文件,后缀当然是js的文件,它里面封装了很多函数方法,我们直接调用即可,就比方说,我们用JS,写一个显示与隐藏,通常是:div.style.display="none/block"这一类,即为显示或者隐藏,而jQuery,它里面做了处理,我们直接这样:$("div").hide() 隐藏,$("div").show() 显示,它在js里就处理了hide和show两个

jquery.extend 学习笔记

//// jquery.extend 学习笔记// jquery.extend 扩展方法设计的很巧妙,动态增加静态方法和属性 // 虽然网上资料很多,还是跟据自已的学习理解记录一下.// //定义一个Person构造函数function Person(iname,iage){ this.uname = iname; this.age = iage;} //定义原型方法Person.prototype = { showN:function(){ //调用静态方法 Person.showName(t

jQuery Mobile学习之grid、等待显示的ajax效果、页面跳转、页面跳转传递参数等(二)

Index.cshtml <!-- Start of second page --> <section data-role="page" id="bar"> <header data-role="header"> <h1>Bar</h1> </header> <!-- /header --> <div role="main" class=

jQuery源代码学习之六——jQuery数据缓存Data

一.jQuery数据缓存基本原理 jQuery数据缓存就两个全局Data对象,data_user以及data_priv; 这两个对象分别用于缓存用户自定义数据和内部数据: 以data_user为例,所有用户自定义数据都被保存在这个对象的cache属性下,cache在此姑且称之为自定义数据缓存: 自定义数据缓存和DOM元素/javascript对象通过id建立关联,id的查找通过DOM元素/javascript元素下挂载的expando属性获得 话不多说,直接上代码.相关思路在代码注释中都有讲解