如何在JavaScript中滑动Range Slider后更改窗口位置

时间:2013-04-17 13:48:04

标签: javascript asp.net-mvc

我在MVC3应用程序中使用Range Slider,

我希望在通过JavaScript更改滑块后更改窗口位置

怎么做?

我的代码

    <script type="text/javascript">
                    $(function () {
                        $("#slider-range").slider({
                            range: true,
                            min: "0",
                            max: "@To",
                            values: ['@from', '@To'],
                            slide: function (event, ui) {
                                $("#amount").val("Rs. " + ui.values[0] + " - Rs. " + ui.values[1]);
                            }
                        });
                        $("#amount").val("Rs. " + $("#slider-range").slider("values", 0) + " - Rs. " + $("#slider-range").slider("values", 1));
                    });   

 slide: function (event, ui) {
           var url = '@Url.RouteUrl("Category", new { categoryId = "_documentId_" })';
           var finalUrl = url.replace('_documentId_', '@catId' + "?price=1000-1200");
           window.location.href = finalUrl;
                    }
        </script>

1 个答案:

答案 0 :(得分:0)

<script type="text/javascript">
                $(function () {
                    $("#slider-range").slider({
                        range: true,
                        min: "0",
                        max: "@To",
                        values: ['@from', '@To'],
                        slide: function (event, ui) {
                            $("#amount").val("Rs. " + ui.values[0] + " - Rs. " + ui.values[1]);
                            var url = '@Url.RouteUrl("Category", new { categoryId = "_documentId_" })';
                            var finalUrl = url.replace('_documentId_', '@catId' + "?price=1000-1200");
                            window.location.href = finalUrl;
                        }
                    });
                    $("#amount").val("Rs. " + $("#slider-range").slider("values", 0) + " - Rs. " + $("#slider-range").slider("values", 1));
                });   

slide: function (event, ui) {

                }
    </script>