Scripts in edit mode - bug

Posted by Community Admin on 03-Aug-2018 22:49

Scripts in edit mode - bug

All Replies

Posted by Community Admin on 24-May-2010 00:00

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

Posted by Community Admin on 25-May-2010 00:00

Could you dynamically add the document.ready to the page if the "cmspagemode" querystring doesn't exist?

Posted by Community Admin on 25-May-2010 00:00

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.

Posted by Community Admin on 25-May-2010 00:00

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.

Posted by Community Admin on 02-Feb-2011 00:00

how can i implement "isDesignMode" on a master page level?

Posted by Community Admin on 02-Feb-2011 00:00

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

Posted by Community Admin on 02-Feb-2011 00:00

thanks radoslav... does that apply to sitefinity 4?

Posted by Community Admin on 02-Feb-2011 00:00

yeah, i don't think there is telerik.cms.... in sitefinity 4.  what is the new path/library/property

Posted by Community Admin on 02-Feb-2011 00:00

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

Posted by Community Admin on 16-Jun-2011 00:00

so what's the deal here?  what's the answer?  how do you implement this in SF 4?

Posted by Community Admin on 16-Jun-2011 00:00

@Will

What is it you need to do?  Are you trying to load scripts in the designer or find the bool page mode helpers?

Posted by Community Admin on 17-Jun-2011 00:00

bool page mode helpers... for SF 4

Posted by Community Admin on 17-Jun-2011 00:00

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 :)

Posted by Community Admin on 17-Jun-2011 00:00

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

This thread is closed