Question

I'm experiencing issues with the order scripts are beeing loaded currently, which results in me getting the error "$ is not defined".

I'm loading the following scripts on the masterpage inside the RadScriptManager Scripts property:

            <asp:ScriptReference Assembly="*.Scripts" Name="*.Scripts.jquery-1.8.1.min.js" />
            <asp:ScriptReference Path="~/Scripts/jquery-ui-1.9.2.min.js" />
            <asp:ScriptReference Path="~/Scripts/development.js" />
            <asp:ScriptReference Assembly="*.Scripts" Name="*.Scripts.STBaseFunctions.js" />
            <asp:ScriptReference Path="~/Scripts/jquery.extensions.js" />
            <asp:ScriptReference Path="~/Scripts/Common.startup.js" />
            <asp:ScriptReference Path="~/Scripts/STBase.startup.js" />

I've made sure to set LoadScriptsBeforeUI="true" (which was the issue for some others on SO) on the scriptmanager.

The problem causes "$" to be unavailable at the time of calling (an extension method which should be provided by "jquery.extensions.js" contained in the Scripts of the ScriptManager)

scriptControl.registerAndExecute('{0}','{1}');

which, to me, does not make sense, since the way i understand it registerclientscript include injects code just before the passed element is beeing rendered, while the scripts given by scriptmanager should be loaded before that as well.

I can't see what i'm doing wrong for this to happen. To my understanding RegisterStartupScript happens once the page is done loading (which goes in line with what i've checked in the source code on the site). However despite the script having been loaded prior to the execution of its functions it does not work.

Does anyone have an idea how to fix this?

Was it helpful?

Solution

Turns out it was an error that occured while changing into the actual site (instead of the testing site).

On the actual site the dockPanel script would register to $(window).resize at the time beeing loaded, which was before jQuery was loaded.

In my testing environment, my dockPanel script would be loaded after the jquery part was already loaded, which made the immediate subscription to the window resize work.

var delayTimer = null;
function getDelayTimer() {
    return delayTimer || (delayTimer = $.utility.delayTimer(dockPanelConstants.resizeTimerDelay));
}

(function () { <!--- fix

    $(window).resize(function () {
        getDelayTimer(function () {

            for (var i = dockpanelResizeHandles.length - 1; i >= 0; i--) {
                var dp = dockpanelResizeHandles[i];
                dp.repaint();
            }
        });
    });
}); <!--- fix
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top