More in this section

Forums / General Discussions / Scripts in edit mode - bug

Scripts in edit mode - bug

14 posts, 0 answered
  1. Lev Rosenblit
    Lev Rosenblit avatar
    37 posts
    Registered:
    14 May 2008
    24 May 2010
    Link to this post
    Hello,
    I have a page with jquery script that runs automatically upon document 'ready' event.
    When I edit this page the script runs over and over again (the script is an overlay popup, and the overlays opens again and again one on top of the other instead of just one as it is when i preview the page).

    I guess the 'ready' event happens again and again in the edit section.

    Lev Rosenblit
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    25 May 2010
    Link to this post
    Could you dynamically add the document.ready to the page if the "cmspagemode" querystring doesn't exist?
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 May 2010
    Link to this post
    Hello Lev,

    Steve is right. You should suppress jQuerry execution if you are in page edit mode. One of the methods is as he describes. The other one is to only add the jQuery script reference and script block if you are not in page edit mode. In Sitefinity 4.0 if the page is being edited it will contain /Action/Edit in the URL.

    Sincerely yours,
    Radoslav Georgiev
    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.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    25 May 2010
    Link to this post
    Hello Steve,

    Just some additional information - we have added an extension method for controls which checks if you are in design mode. If you have a user control which is going to be used within Sitefinity you can check if you are in design mode using this.IsDesignMode():
    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsDesignMode())
            {
            }
     
        }
    }

    We are not going to have a query string cmspagemode in the Sitefinity 4.0 version, so checking for design mode as above is the cleanest way.

    Greetings,
    Radoslav Georgiev
    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. GCM
    GCM avatar
    11 posts
    Registered:
    29 Jul 2007
    02 Feb 2011
    Link to this post
    how can i implement "isDesignMode" on a master page level?
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    02 Feb 2011
    Link to this post
    Hi Webmaster,

    You can check this forum thread which explains how to check if a page is in edit mode from the master page level.

    Best wishes,
    Radoslav Georgiev
    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
  7. GCM
    GCM avatar
    11 posts
    Registered:
    29 Jul 2007
    02 Feb 2011
    Link to this post
    thanks radoslav... does that apply to sitefinity 4?
  8. GCM
    GCM avatar
    11 posts
    Registered:
    29 Jul 2007
    02 Feb 2011
    Link to this post
    yeah, i don't think there is telerik.cms.... in sitefinity 4.  what is the new path/library/property
  9. GCM
    GCM avatar
    11 posts
    Registered:
    29 Jul 2007
    02 Feb 2011
    Link to this post
    after a lot of digging with a co-worker we found these properties to use in the master page:
    Telerik.Sitefinity.Services.SystemManager.IsDesignMode
    Telerik.Sitefinity.Services.SystemManager.IsPreviewMode
  10. Will
    Will avatar
    10 posts
    Registered:
    16 Mar 2011
    16 Jun 2011
    Link to this post
    so what's the deal here?  what's the answer?  how do you implement this in SF 4?
  11. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    16 Jun 2011
    Link to this post
    @Will

    What is it you need to do?  Are you trying to load scripts in the designer or find the bool page mode helpers?
  12. Will
    Will avatar
    10 posts
    Registered:
    16 Mar 2011
    17 Jun 2011
    Link to this post
    bool page mode helpers... for SF 4
  13. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    17 Jun 2011
    Link to this post
    Theres a few like Radoslav shows

    this.IsDesignMode()
    this.IsBackend()

    etc...

    You just need to have one of these namespaces defined for those extensions methods to show up though
    using Telerik.Sitefinity.Modules.Pages.Web.UI;
    using Telerik.Sitefinity.Web.UI;
    using Telerik.Sitefinity.Web.UI.ControlDesign;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.Model;

    On the top of my head I'm not sure EXACTLY which :)
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Jun 2011
    Link to this post
    Hi ,

    IsDesignMode - static method which determines whether the control is in Sitefinity design mode - you  are editing a page. There are also
    IsPreviewMode- determines whether the control is in Sitefinity preview mode.

    IsBackend -determines whether a control instance is in backend.

    sample

    protected override void OnPreRender(EventArgs e)
    {
             base.OnPreRender(e);          
             if(this.IsDesignMode() && !this.IsPreviewMode())
             {
                 this.Controls.Clear();

             }
           
       }




    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
14 posts, 0 answered