More in this section

Forums / General Discussions / jQuery in 4.0 RC 2 and $telerik is not defined

jQuery in 4.0 RC 2 and $telerik is not defined

9 posts, 0 answered
  1. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    07 Jan 2011
    Link to this post
    We have upgraded to SF 4.0 RC 2 and now, 2 custom control widgets that we made, lock-up the edit-a-page screen.  We can drag them to a drag-widgets-here box, and publish the page, but when we open the page, in the edit-a-page screen for editing, that screen (the edit-a-page screen) pretty much has none of the functionality that it should have: the Publish button does not appear, the buttons across the top which are visible do nothing, and you cannot drag any of the widgets - neither SF ones, nor our custom ones.  AND Firebug shows us that the page gets an error:  "$telerik is not defined."

    We used the js from the tutorial  here
     http://www.sitefinity.com/4.0/documentation/how-to-create-a-widget/advanced/writing-the-javascript-for-the-dialog.aspx

    So to reproduce the error you should be able to try to put a custom control widget, that you created based on that tutorial, is a SF 4.0 RC 2 version of Sitefinity.

    Is it possible that the jQuery and/or javascript in SF 4.0 RC 2 was changed in a way to create this issue?

    Thanks
    Phil

  2. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    07 Jan 2011
    Link to this post
    Hi Phil,

    I had this same problem (even before RC2). My work around is to load the jquery files in the code behind of my custom master page template file. When I load them I check to see if I'm in design mode and if I am I don't load the jquery scripts. It means in the backend all my custom js functionality doesn't work but at least it doesn't kill the backend and disable admin functionality (the edit buttons for content areas disappear).
    protected override void OnPreRender(EventArgs e)
    {
        // Register Client Scripts
        if (!this.IsDesignMode())
        {
            this.Page.ClientScript.RegisterClientScriptInclude("jquery", "/custom/scripts/jquery.js");
            this.Page.ClientScript.RegisterClientScriptInclude("jqueryui", "/custom/scripts/jquery-ui.min.js");
        }
        base.OnPreRender(e);
    }

    Hope that helps to at least work around the issue.

    Cheers,
    Phill
  3. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    07 Jan 2011
    Link to this post
    Hmmmmm.  Well, I dont want to give up that functionality in the edit-a-page screen.  But more importantly, doing without the js file is not at all an option for me because it is central to getting the values, which the user has entered, from the control designer, to the widget ascx in the edit-a-page screen.

    So, Sitefinity, I still need advise on this.

    Phil.
  4. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    07 Jan 2011
    Link to this post
    Perhaps check Eric's solution here 
    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/jquery-plugins-and-or-authoring-custom-jquery-functions-not-supported.aspx

    He had a case where jQuery was being re-defined and custom functions were lost, perhaps this is similar to what's happening in your case.

    Phill
  5. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    08 Jan 2011
    Link to this post
    Thanks Phil.  Eric's solution looks interesting.  I was not able to apply it and I have a question in to him.

    Eric calls his solution hacky and hopes for an answer from SF.

    I also, would like SF to weigh in on this and give us a solution.  Even though your situation, Phil, was before RC 2, there are 3 of us that had everything working fine before RC 2 but now are having this $telerik undefined issue.

    Sitefinity, please advise.
  6. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    09 Jan 2011
    Link to this post
    I was wondering about this myself...in the javascript samples they use "jQuery" as the prefix instead of $ or $telerik
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    11 Jan 2011
    Link to this post
    Okay, I just encountered this error now...This works for me...

    $(document).ready(function () {
            if (!$telerik.$ == true)
                $telerik.$ = jQuery;
    });


    Seems to happen when I drop in a layout control which contains a radcontrol.  Then switch back to widgets and try to drop in another control (I get the $telerik.$ is undefined).  Inspecting the net tab in firebug it seems like the control downloads the required scripts which use $telerik.$ however I'm guessing whatever core script which defines $telerik.$ as an object isn't there.

    The above code fixes it though (in my case)
  8. Phil
    Phil avatar
    89 posts
    Registered:
    19 Oct 2010
    11 Jan 2011
    Link to this post
    I applied Steve's fix and was very happy that I could go to the edit-a-page screen and back to the page list screen over and over w no errors and all the functionality on all screens was fine.

    Then I hit the Preview button and I got an error:  "$ is not defined".  In Preview, it is erroring on the line of code that is the fix for the edit-a-page screen.
    $(document).ready(function() {

    Thanks for all the ideas so far.  Any ideas re this?

    Thanks
  9. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    11 Jan 2011
    Link to this post
    Is jQuery loaded on your page (not the backend)?

    What's the script error?
9 posts, 0 answered