滑块在 jQuery Mobile 中不起作用

发布于 2024-12-11 04:04:21 字数 714 浏览 0 评论 0原文

我正在 jQuery Mobile 中尝试滑块小部件,只是从文档中复制了代码:

    <div data-role="fieldcontain">
        <label for="slider">Input slider:</label>
        <input type="range" name="slider" id="slider" value="0" min="0" max="100"/>
    </div>

但这根本无法按预期工作。当我在 Safari 中拖动滑块时,数字几乎随机变化。它们从 0 增加到 9,然后在滑块的最右侧它又回到 0,然后当我向后滑动时,它在 0 和 9 之间来回移动...

我做错了什么吗?

我在 CodeIgniter 应用程序中使用它。

编辑:

我刚刚发现它实际上可以在 iPhone 上运行,但不能在桌面上的 Safari 中运行。这仍然很奇怪,因为首先我需要它在桌面上进行开发,其次,它可以在 jQuery Mobile 演示网站上运行...我尝试查看该代码,甚至完全复制它,但仍然如此在我的页面上不起作用。

我已经更新到 RC2,而演示页面上的脚本仍然是 beta 2,可能是这样吗?

编辑2:

不,不是这样...我已经检查了旧文档,但是最新版本的新文档中的示例在其演示页面上也运行良好。所以这是另一回事。

I'm trying the slider widget in jQuery Mobile, and just copied the code from the docs:

    <div data-role="fieldcontain">
        <label for="slider">Input slider:</label>
        <input type="range" name="slider" id="slider" value="0" min="0" max="100"/>
    </div>

But this doesn't work as expected at all. When I drag the slider in Safari the numbers change almost randomly. They increase from 0 to 9 and then at the far right of the slider it goes back to 0, and then when I slide back it goes back and forth between 0 and 9...

Am I doing something wrong??

I am using this inside a CodeIgniter application.

EDIT:

I just found out that it actually works when live on the iPhone, but not in Safari on the desktop. It's still weird, because first of all I need it to work on the desktop for development, and secondly, it works on the jQuery Mobile demo site... I have tried looking at that code, and even copying it exactly, but still it doesn't work on my page.

I have updated to RC2, while the script on the demo page is still beta 2, could that be it?

EDIT 2:

No, that was not it... I had checked the old docs, but the example in the new docs with the latest release worked fine on their demo page as well. So it's something else.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

极度宠爱 2024-12-18 04:04:21

请记住,jqueryMobile 1.0.1 版本与 jquery 1.7.1 不完全兼容,这使得滑块无法在某些浏览器上工作。
尝试将 jquery 降级到版本 1.6.4,滑块应该开始工作

keep in mind that version 1.0.1 of jqueryMobile is not fully compatible with jquery 1.7.1 and this makes the slider not working on some browsers.
Try to downgrade jquery to version 1.6.4 and the slider should start working

番薯 2024-12-18 04:04:21

嗯不确定您的代码中还发生了什么,这是一个示例:

滑块文档:

HTML

<div data-role="page" id="slider-test">
    <div data-role="content">

        <label for="slider-0">Input slider:</label>
        <input type="range" name="slider-1" id="slider-0" value="2" min="0" max="10"  />
        <br />
        <div data-role="fieldcontain">
            <label for="slider">Input slider:</label>
            <input type="range" name="slider" id="slider" value="0" min="0" max="100"/>
        </div>

    </div>
</div>

顺便说一句,我在 Ubuntu 10.04 上使用 Chrome,如果重要的话,这可能是 Safari 桌面问题。尝试使用其他浏览器,因为您的代码对我来说看起来不错

Hmm not sure what else is going on in you code, here is an example:

Slider Docs:

HTML

<div data-role="page" id="slider-test">
    <div data-role="content">

        <label for="slider-0">Input slider:</label>
        <input type="range" name="slider-1" id="slider-0" value="2" min="0" max="10"  />
        <br />
        <div data-role="fieldcontain">
            <label for="slider">Input slider:</label>
            <input type="range" name="slider" id="slider" value="0" min="0" max="100"/>
        </div>

    </div>
</div>

BTW Im using Chrome on Ubuntu 10.04 if that matters, this might be a Safari desktop issue. Try using another browser as your code looks fine to me

北城挽邺 2024-12-18 04:04:21

我自己找到了答案。当我查看 Safari 中的 Web 检查器时,jQuery Mobile 样式表已将输入字段的宽度设置为 50px。如果我将其增加到 70px,我注意到这些值实际上在增加,只是我之前只看到了左边的数字。奇怪的是,即使使用相同的样式表,它似乎在他们的演示网站上运行良好!无论如何,我通过覆盖该规则并将其设置为 70px 来使其工作。

Sort of found the answer myself. The jQuery Mobile stylesheet when I looked in the web inspector in Safari had set the width of the input field to 50px. If I increased that to 70px I noticed that the values were in fact increasing, it was just that I only saw the left digit before. Strangely, it seems to be working fine on their demo site, even though the same stylesheet is used! Anyway, I got it working by overriding that rule and setting it to 70px.

乜一 2024-12-18 04:04:21

我注意到了同样的问题,但我相信这是由于使用实验性滚动视图...如果我注释掉我的滚动视图脚本,翻转开关滑块将再次工作。

I have noticed this same issue but I believe it is due to using the experimental scrollview... If I comment out my scrollview scripts the flips switch slider works again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文