+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / RADMenu Javascript error when disabling Embedded Scripts

RADMenu Javascript error when disabling Embedded Scripts

7 posts, 0 answered
  1. Josh
    Josh avatar
    4 posts
    Registered:
    16 Jul 2010
    16 Jul 2010
    Link to this post
    Hi. I'm using the RADMenu to build the menu for a site but disabled the Embedded Javascript because we wanted to do just flyouts in a specific manner.

    I was able to remove the embedded script and everything was fine last night, but this morning I'm getting the following Javascript error:

    Telerik is not defined
    $create(Telerik.Web.UI.RadMenu, {"...00_SideBarContent_ctl00_RadMenu1"));
    http://localhost/
    Line 209

    This is the block of code being referenced:
    <script type="text/javascript">
    //<![CDATA[
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(Telerik.Web.UI.RadMenu, {"_childListElementCssClass":null,"_skin":"Default","attributes":{"GroupCssClass":"rmGroupMenu"},"clientStateFieldID":"ctl00_SideBarContent_ctl00_RadMenu1_ClientState","collapseAnimation":"{\"duration\":450}","expandAnimation":"{\"duration\":450}","itemData":[{"attributes":{"PageID":"d91d729f-d656-47b0-9d77-a8b82f3ab005"},"items":[{"attributes":{"PageID":"3065cd79-add9-4de9-b9f1-5a4e8b107127"},"items":[{"attributes":{"PageID":"5bae3db2-b5e2-44a6-b2c4-1dbb73a4fb7e"},"value":"Headwear","navigateUrl":"~/Men/Products/Headwear.aspx"}],"value":"Products"}],"value":"Men","navigateUrl":"/shop/men.aspx"}]}, null, null, $get("ctl00_SideBarContent_ctl00_RadMenu1"));
    });
    //]]>
    </script>
    

    Is there anyway to keep the control from registering this call?

    Thanks in advance.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Jul 2010
    Link to this post
    Hello Josh,

    Embedded scripts and base stylesheets should not be disabled. You cannot disable completely the scripts. Here is a link to a posts RadMenu for ASP.NET Ajax - Working with disabled JavaScript that explains how you can work with RadMenu and disabled scripts. You need to add some custom scripts or css classes that will allow you to use some of the basic features of the control. This is an AJAX control. Another option is creating a custom control that do not use any js and AJAX

    All the best,
    Ivan Dimitrov
    the Telerik team
     
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
     
  3. Josh
    Josh avatar
    4 posts
    Registered:
    16 Jul 2010
    16 Jul 2010
    Link to this post
    Thanks for the fast reply, Ivan. Unfortunately it appears that the link you included is broken.

    The RADMenu is part of a custom control. It only has the Embedded scripts disabled when not in the admin area. This way the control is still editable and not totally disabled.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Jul 2010
    Link to this post
    Hi Josh,

    Here is the updated link . You can place the control in a user or custom control. Then in PageLoad you can check whether  you are in edit mode or not. If you are in edit mode enable RadMenu scripts, otherwise they will be disabled

    if(HttpContext.Current.Request.QueryString[ "cmspagemode"] == "edit")
        {
           //here disable RadMenu scripts
        }


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Josh
    Josh avatar
    4 posts
    Registered:
    16 Jul 2010
    16 Jul 2010
    Link to this post
    Thanks for the link, Ivan. I actually found that yesterday when researching how to disable the embedded scripts.

    The solution you posted is similar to what I implemented. I did the "IsPageInAdmin" one.

    private bool IsPageInAdmin()
    {
        string mode = this.Page.Request.QueryString["cmspagemode"];
        if(mode == "edit" || mode == "preview")
        {
            return true;
        }
        return false;
    }

    The problem is happening when the page is being shown on the front, mainly. I found the problem that was causing the error on the admin side.

    The embedded scripts are being disabled and are not being included on page load. The problem is that the initialization is still being called even though the scripts have been disabled. Is there a workaround?

    When the $create(Telerik.Web.UI.RadMenu, {"...00_SideBarContent_ctl00_RadMenu1")); is being fired, can I "fake" it? It seems that the error is being caused by the Telerik object not being defined. Are no base scripts included when Sitefinity renders the page?
  6. Josh
    Josh avatar
    4 posts
    Registered:
    16 Jul 2010
    16 Jul 2010
    Link to this post
    I've been able to narrow down that the problem is stemming from the RadMenu adding:
    Sys.Application.add_init(function(){$create(Telerik.Web.UI.RadMenu, {"_childListElementCssClass"...));});

    Even though the RadMenu knows that the Embedded scripts have been disabled, it's still trying to make a call to create the RadMenu object.

    So, my solution was to overwrite the initialize function for the RadMenu.
    Telerik.Web.UI.RadMenu.prototype.initialize = function() {};

    I re-enabled the Embedded scripts so that all the rest of the functionality works.

    So, it's not fixed or working as I would have hoped, but it is working. Thanks for the assist.
  7. Joe Hakooz
    Joe Hakooz avatar
    2 posts
    Registered:
    22 Dec 2007
    06 Aug 2010
    Link to this post
    Nice one Josh! I'm not using RadMenu in Sitefinity, but this is exactly what I needed.

    I agree though. It would be nice if the $create(Telerik.Web.UI.RadMenu... were not called at all in my scenario, but I can live with it. Let's face it... ASP.NET has made us all a little numb to bloated HTML source... :-)

    Joe

    EDIT
    I wrapped Josh's "fix" in a function so that it didn't fail when RadMenu was visible="false"...

    <script type="text/javascript">
        function OnClientLoad() {
            Telerik.Web.UI.RadMenu.prototype.initialize = function() { };
        }
    </script>
    <telerik:RadMenu ID="RadMenu1" Visible="true" OnClientLoad="OnClientLoad" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" EnableEmbeddedScripts="true">
    </telerik:RadMenu>
Register for webinar
7 posts, 0 answered