I have already styled and implemented jQuery UI slider into a project. Though it's responsive, the slider does not respond to being touched and dragged. Instead, you have to touch where you want the slider to go. I'd like to avoid swapping to jQuery mobile UI, which supports touching and dragging, since we already extensively use jQuery (non-mobile) UI.

The functionality we want: Here
What we are using: Here

On a desktop you can't tell the difference. On a mobile device it is apparent.

Anyone know how to add this support to jquery UI?

$("#videographers").slider({
  value: 2,
  min: 1,
  max: 3,
  step: 1,
  slide: function(event, ui) {
    return calcTotal(ui.value);
  }
});

推荐答案

jQuery UI不支持touch .你应该把它和jQuery-ui touch punch一起使用.

只需在jQuery ui之后添加脚本:

<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js"></script>
<script src="jquery.ui.touch-punch.min.js"></script>

您也可以使用CDNJ:

<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>

Note: Better give this repo a star on Github.

Jquery相关问答推荐

这是否会导致内存泄漏?

使用 Bootstrap 3 下拉菜单作为上下文菜单

Bootstrap 的工具提示在悬停时将表格单元格向右移动一点

jQuery找到最近的匹配元素

Ajax 替换而不是追加

jQuery 的元素或类 LIKE Select 器?

标识符 (id) 是否有通配符 Select 器?

仅在 _some 字段上通过 Enter 键禁用表单提交

不使用插件的 jQuery 缓动函数

如何在 JQuery UI 自动完成中使用 source:function()... 和 AJAX

未捕获的语法错误:无法在文档上执行querySelector

iframe 仅显示页面的特定部分

blueimp 文件上传插件中的 maxFileSize 和 acceptFileTypes 不起作用.为什么?

单击后如何禁用提交按钮?

jQuery中的Grep与过滤器?

$(document).ready(function(){});页面底部的 vs 脚本

使用 jQuery 获取选中复选框的值

获取jQuery中下拉列表的值

'touchstart' 事件是否有与点击事件相同的 e.PageX 位置?

Bootstrap:在 Modal 中打开另一个 Modal