ghusse / jQRangeSlider

A jquery UI range selection slider that supports dates
http://ghusse.github.com/jQRangeSlider/
GNU General Public License v3.0
671 stars 147 forks source link

jQRangeSlider always show the last date #176

Open irineuruiz opened 9 years ago

irineuruiz commented 9 years ago

I'm using jQRangeSlider, and everything works fine, except the fact that the last Date always appears in the range slider.

Follows the code generated in the browser, as you can see, appears the last date, in this case (24/07/2014) and this date are always visible in the browser :

                    var ontem = new Date();
                    var ontemValue = ontem.getTime() - 1000 * 60 * 60 * 24 * 1; // 1 dia
                    ontem.setTime(ontemValue);

                    var tresMeses = new Date();

                    var tresMesesValue = tresMeses.getTime() - 1000 * 60 * 60 * 24 * 20; // 20 dias
                    tresMeses.setTime(tresMesesValue);

                    if ($("#slider") != null) {
                        $("#slider").dateRangeSlider({
                            bounds: { min: tresMeses, max: ontem },
                            //step: { days: 1 },
                            defaultValues: { min: tresMeses, max: ontem },
                            formatter: function (val) {
                                var days = val.getDate(),
                                month = val.getMonth() + 1,
                                year = val.getFullYear();
                                if (("" + days).length == 1) days = "0" + days;
                                if (("" + month).length == 1) month = "0" + month;
                                return days + "/" + month + "/" + year;
                            }
                        });

                        $("#slider").on("valuesChanged", function (e, data) {
                            console.log("Something moved. min: " + data.values.min + " max: " + data.values.max);
                            angular.element(document.getElementById('controles')).scope().setJQRange(0, data.values.min, data.values.max); //0 -> $parent.$index
                       });
                    }

problemjqrangeslider

05/07/2014
24/07/2014
```
11/07/2014
16/07/2014
```
ghusse commented 9 years ago

Can you create a live example with jsfiddle? You can use this one as a starting point http://jsfiddle.net/ghusse/vM844/