是否可以在非移动网页中使用单个jQuery移动小部件? [英] Is it possible to use a single jQuery mobile widget within a non-mobile web page?

查看:79
本文介绍了是否可以在非移动网页中使用单个jQuery移动小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI将一些小部件放置在主要用于大屏幕的网页上. 我正在寻找一个 flipswitch 小部件,并且发现了jQuery移动框架提供的一个小部件.

I am using jQuery UI to put some widgets on a web page primarily designed for large screens. I was looking for a flipswitch widget, and I found one provided by jQuery mobile framework.

是否可以使用jQuery mobile来使该flipswitch小部件起作用,而无需整个jQuery mobile主题化?

Is it possible to use jQuery mobile to just make this flipswitch widget work, without the whole jQuery mobile theming ?

推荐答案

您可以通过创建自定义构建.您要做的就是选择所需的小部件,然后加载JS库以及样式表.您还需要通过手动修改样式表或使用 ThemeRoller 修改样式表.

You can use jQuery Mobile's widgets by creating a custom build. All you have to do is to choose the widgets you want, and then load JS library as well as style sheets in head. You will also need to modify style sheets, either by modifying them manually or using ThemeRoller.

HTML

<head>
  <link rel="stylesheet" href="structure.css" />
  <link rel="stylesheet" href="theme.css" />
  <script src="jquery-1.11.1.min.js"></script>
  <script src="custom-build.js"></script>
</head>
<body>
  <form>
    <label for="flip-checkbox-1">Flip toggle switch checkbox:</label>
    <input type="checkbox" data-role="flipswitch" name="flip-checkbox-1" id="flip-checkbox-1">
  </form>
</body>

要初始化小部件,只需在.ready()上调用.flipswitch().有关更多方法,请检查小部件的 API .

To initialize the widget, just call .flipswitch() on .ready(). For more methods, check widget's API.

$(function () {
  $("#flip-checkbox-1").flipswitch();
});

演示

Demo

这篇关于是否可以在非移动网页中使用单个jQuery移动小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆