jQuery Mobile,设置滑块的值
滑块目前渲染得很好,它只是没有按照我的指示去做。
我无法使用 $('#slider').val(50).slider('refresh')
,并且 当我这样做时它告诉我:
Uncaught 无法在初始化之前调用滑块上的方法; 尝试调用方法“刷新”
这似乎是有道理的,因为我从未将其初始化为滑块。这是我的代码: 早些时候,我创建了一个 div ""
并将其写入屏幕 $(cssSelector.html(html);< /code> 然后,一旦代码的其他部分准备就绪,我就创建滑块:
$('#scrubber').html('<input type="range" name="prog" id="prog" value="0" min="0" max="'+event.jPlayer.status.duration+'" />').trigger("create");
:
$('#scrubber').val(event.jPlayer.status.currentTime).slider('refresh');
这给了我这个错误。
然后 但这似乎创造了然后我尝试替换第一个滑块,但它只会让事情变得更加混乱,在任何情况下,如果我尝试更改该值,我将不再收到错误,但它仍然没有改变。滑块的位置
有什么想法吗?
The slider currently renders fine, it just doesn't do what I tell it to.
I can't use $('#slider').val(50).slider('refresh')
, and
when I do it tells me:
Uncaught cannot call methods on slider prior to initialization;
attempted to call method 'refresh'
Which, seems to make sense, since I never initialized it as a slider. Here is my code:
Somewhere earlier I create a div "<div id='scrubber'></div>"
and just write it to the screen $(cssSelector.html(html);
Then once some other part of the code is ready I create the slider:
$('#scrubber').html('<input type="range" name="prog" id="prog" value="0" min="0" max="'+event.jPlayer.status.duration+'" />').trigger("create");
Then later:
$('#scrubber').val(event.jPlayer.status.currentTime).slider('refresh');
Which gives me that error.
I have tried using $('#scrubber').slider();
but that seems to create a 2nd slider. So then I tried to replace the first slider, but it just messes things up even more. In any case, if I then try to change the value, I no longer get the error, but it still doesn't change the slider's position.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经有一段时间没有使用 jQM 了,但是它还有 .page() 函数吗?
如果是这样,请在滑块包装器上调用 page():
这将重新渲染滑块,使其正确初始化。
I haven't worked on jQM for a while, but does it still have the .page() function?
If so call page() on the sliders wrapper:
This will re-render the slider, causing it to be properly initialised.