0

This is my jquery function which I call:

var spinSeconds = function(event, ui, id) {
            if (ui.value >= 60) {
                $(this).spinner('value', ui.value - 60);
                $("#" + id).spinner('stepUp');
                return false;
            } else if (ui.value < 0) {
                $(this).spinner('value', ui.value + 60);
                $("#" +  id).spinner('stepDown');
                return false;
            }
        }

This is where I call it:

$('#seconds').spinner({
    spin: spinSeconds(event, ui, "minutes")
});

When I try to pass id as an argument and call it like above, my function does not work and gives

"Uncaught ReferenceError: ui is not defined"

on console. What is the correct way to call it?

UPDATE:

You can see jsfidle here: https://jsfiddle.net/86Lwhmem/

ismailcem
  • 161
  • 1
  • 16

1 Answers1

0

Try this : defined your jquery function like below but before calling it. call it in same manner as you have posted. It should work.

var  spinSeconds = function(event, ui, id) {
            if (ui.value >= 60) {
                $(this).spinner('value', ui.value - 60);
                $("#" + id).spinner('stepUp');
                return false;
            } else if (ui.value < 0) {
                $(this).spinner('value', ui.value + 60);
                $("#" +  id).spinner('stepDown');
                return false;
            }
        };
Bhushan Kawadkar
  • 27,451
  • 5
  • 33
  • 55