0

I am new to JS and Jquery and I am trying to come up with solution to my problem. Here is the jQuery Slider plugin which I would like to incorporate

I have an array with 1,000-2,000 objects. Each object has a time and the Unique Id. Time example:

2013-01-23 23:59:03
2013-01-23 23:58:33
2013-01-23 23:58:03
2013-01-23 23:57:33
2013-01-23 23:57:02
2013-01-23 23:56:33

I need to make sure that slider has all times loaded into it's range, and each time when I move the slider, I want to see an event, where I have the time, and the addMarker(my unique id) function triggered.

I tried loading values via $( ".selector" ).slider( "values", [ 'my time 1', 'my time 2'] ); but seems like I am not doing it right. JS and Jquery are still new to me.

Andrew
  • 7,619
  • 13
  • 63
  • 117
  • You should be using integers for the slider values, and then convert those integeres to the right times. You can't expect the UI slider to understand your strings containing dates etc. The value option sets the values for the handles only, it's all in the docs ? – adeneo Jan 27 '13 at 19:17

1 Answers1

0

In order to do it, I had to create an array of hash-maps and create response to each event and call to element in hash-map

            $(function() {
                $( "#slider-range-max" ).slider({
                    range: "max",
                    min: 1,
                    //declare maximum which is the amount of elements in array
                    max:  polyArray.filter(function(value) {
                        return value !== undefined
                    }).length,
                    value: 2,
                    slide: function( event, ui ) {
                        var cRte= {};
                        //access my hash map
                        cRte = History[ui.value]; 
                        try { 
                        alert(cRte["timestamp"]);
                        } catch(e) {
                            console.log(e);
                        }
                    }
                });
            });
Andrew
  • 7,619
  • 13
  • 63
  • 117