开发者

Multiple jquery-ui sliders

I'm having some problems using multiple sliders at the same time.

In the html I have something like:

<div id="slider1"></div>
<div id="slider2"></div>

And in the javascript:

$("#slider1").slider({
    slide: function(event, ui) { alert("slider 1 slided"); }
});

$("#slider2").slider({
    slide: function(event, ui) { alert("slider 2 slided"); }
});

Both sliders appear, but when moving slider1 it displays th开发者_如何学JAVAe alert "slider 2 slided". If I add more sliders the behaviour is the same, all sliders call the event for the last registered slider.

Am I missing something or is this a bug in jquery-ui?

This is jquery 1.4.2 with jquery-ui 1.8.6


Here is what you posted expanded out into a full working example, and everything works correctly. You'll need to post more code that fully duplicates the issue before anyone will be able to help you.

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.6/jquery-ui.min.js"></script>

<link href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.6/themes/dark-hive/jquery-ui.css" type="text/css" rel="stylesheet"/>

<div id="slider1"></div>

<br/>

<div id="slider2"></div>

<script>
    $(function(){

        $("#slider1").slider({
            slide: function(event, ui) { alert("slider 1 slided"); }
        });

        $("#slider2").slider({
            slide: function(event, ui) { alert("slider 2 slided"); }
        });

    });
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜