JavaScript callback function failed

I am trying to implement the functionality of a slider I found here . However, I cannot get the functionality to callbackwork correctly. The page I'm trying to get her to work with is very simple in that I'm trying to get her to call a function when the slider value changes: http://dev.itap.purdue.edu/dev/sandbox/jfish/slider.html .

I assume I made some simple javascript error, but without a lot of documentation, I was kind of stuck at this point. Any help would be greatly appreciated.

+3
source share
5 answers

There fd-slider.jsis an error on line 446 of the function in which it tries to call each callback functionfunc.call(inp, cbObj);

The variable is cbObjundefined, so callbacks are not called. I fixed this by updating these few lines, just to determine that var.

for(var i = 0, func; func = callbacks[type][i]; i++) {
    var cbObj = null;
    func.call(inp, cbObj);
};

I could not find the definition of the callback object anywhere in the code.

+2
source

the callback should point to a function, for example, the following code

callbacks:{"move":[doAlert]}

but instead you point to the result of the function when you use ()at the end doAlert. This is why it shows a warning when loading the page

+2
source

?

callbacks:{"move":function(){ doAlert(); }}
+1

callbacks:{"move":[doAlert]}
0

. :

callbacks:{change:[doalert]}

, , , doalert,

function(fdevent){alert(fdevent.value)}

Your notification will indicate the value of your slider.

read callback functions http://www.frequency-decoder.com/2010/11/18/unobtrusive-slider-control-html5-input-range-polyfill/

0
source

All Articles