动态更改jquery ui滑块中的价格范围

时间:2013-01-04 05:23:37

标签: javascript jquery ruby-on-rails ruby-on-rails-3 jquery-ui

我正在尝试使用jquery滑块工作价格范围, 这是它的工作原理,

当用户选择滑块并调整滑块的一侧时,滑块中的值将传递给我的控制器并执行,方法是将参数添加到url并刷新页面。

出了什么问题: 当用户调整滑块的任何一侧时,参数正确并正确执行,但刷新页面后,滑块范围值将变为默认值,我不想,i希望他们根据参数值(price_min,price_max)

var PropertyPriceFilter = { min:100000, max:10000000 };
     $("#filtered-price").val((PropertyPriceFilter.min) + " - " + (PropertyPriceFilter.max));


        $("#property_price").slider({

            range:true,
            min:PropertyPriceFilter.min,
            max:PropertyPriceFilter.max,

            values:[ 100000, 10000000 ], //dynamically change values using values present in the params["price_min"] & params["price_max"]
              slide:function (event, ui) {
                $("#filtered-price").val(("Rs." + ui.values[ 0 ]) + " - " + "Rs." + (ui.values[ 1 ]))
                PropertyPriceFilter.min = ui.values[ 0 ]
                PropertyPriceFilter.max = ui.values[ 1 ]

            window.location += '&price_min=' + PropertyPriceFilter.min + '&price_max=' + PropertyPriceFilter.max;
        }
    });

__ _ _ _这是从params改变值的if else条件,有逻辑上正确,但仍然无法正常工作,我不知道为什么

if ((params["price_min"] != null) || (params["price_max"] != null))
{

    if ((params["price_min"] != null) && (params["price_max"] = null)) {
        var price_min = parseInt(params["price_min"])
        var price_max = 10000000
    }
    else if ((params["price_min"]) = null && (params["price_max"]) != null) {
        var price_min = 100000
        var price_max = parseInt(params["price_max"])
    }
    else if ((params["price_min"]) != null && (params["price_max"]) != null) {
        var price_min = parseInt(params["price_min"])
        var price_max = parseInt(params["price_max"])
    }
}
else
{
    var price_min = 100000
    var price_max = 10000000
}

0 个答案:

没有答案
相关问题