Chris
Chris

Reputation: 3129

SetInterval won't stop running

I have a function that uses setInterval, and it keeps running and it doesn't want to stop. The code I wrote is

let findGrid = setInterval(function () {
    if (grid == null) {
        grid = $('#QuickEntryGrid').getKendoGrid();
    }
    else {
        clearFindGrid;
        console.log("Found Grid");
        console.log(grid.dataSource.view());
    }
}, 100);

let clearFindGrid = function () {
    clearInterval(findGrid);
};

if (grid != null) {
    grid.setOptions({
        width: (newInnerVerticalWidth - 2) + "px"
    });
    $("#QuickEntryGrid").find("table").on("keydown", onGridKeydown);
}

It keeps hitting the console.log(grid.dataSource.view());

Upvotes: 0

Views: 83

Answers (1)

AlTheLazyMonkey
AlTheLazyMonkey

Reputation: 1242

You must call the funcion with the brakets clearFindGrid()

Upvotes: 1

Related Questions