Content script can't see initialization spinner

Content script can't see initialization spinner

Hey,

I've been writing a content script to do some form filling. The website I am trying to do this on uses the jquery spinner widget for one of the values. Using the Chrome console and manually performing every command, all of this works fine. However, when I try to let the script run it I get this error:

  1. Uncaught Error: cannot call methods on spinner prior to initialization; attempted to call method 'value'
        at Function.error (jquery.js:253)
        at HTMLInputElement.<anonymous> (jquery-ui.min.js:6)
        at Function.each (jquery.js:370)
        at jQuery.fn.init.each (jquery.js:137)
        at jQuery.fn.init.t.fn.<computed> [as spinner] (jquery-ui.min.js:6)
        at myScript.js:96

HTML:
  1. <div class="spinbox">
        <div class="title">...<div>
    <div class="inputs" style="height: 49px;">
        <input type="tel" id="input-ID" data-win-bind="disabled: AmountSpinnerEnabled Converters.not" aria-valuemin="0.5" aria-valuemax="4750" class="ui-spinner-input" autocomplete="off" role="spinbutton" aria-valuenow="100">
    <button class="icon-plus ui-spinner-button ui-spinner-up ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button">...</button>
            <button class="icon-minus ui-spinner-button ui-spinner-down ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button">...</button>
    </div>
    </div>

Code:
  1. if(window.location.href == "website.com") {
    $( window ).on('load', function(){
            var x = 100
            var y = 200

            document.getElementsByClassName("dropdown")[1].click();
    setTimeout(function () {
        console.log("set amount")
        $("#input-ID").spinner("value", x);
        setTimeout(function () {
        document.getElementById("checkbox").click()
                }, 2000);
            }, 2000);
        }
    }

Using $(document).ready(function(){... does not change anything. If I let the script run and then right after it selects the dropdown menu I execute  $("#input-ID").spinner("value", x); in the Chrome console it works fine and changes the value. Right after that though, it still gives me the same error when the script tries to run this same line.

Is there a certain way you have to initialize the spinner in a content script? I assumed I didn't have to do this because the site itself initializes it.