Detecting if your SharePoint 2010 page is in “Edit” mode with jQuery

Revision: This seems to work best on or with Publishing Pages. Errors might occur within document libraries, list libraries, the Edit screen/dialog for documents, etc.

————————————-

I had to stop a slide show from running and allow me to actually edit a page without getting in the way. I built the slide show originally, so it was my baby. I had to find a way let my script detect when the page was in edit mode.

Searching the net gave me a wide range of solutions that were all over the place. I need something simple and easy; SharePoint 2010 HAS to have a session state…. Good thing it uses a built-in JavaScript variable to do just this called g_disableCheckoutInEditMode. Go ahead and try it:

$(document).ready(function() {
if(!g_disableCheckoutInEditMode)
{
*insert what you want to do when not in edit mode*
}
});

Source: http://community.zevenseas.com/Blogs/Tanmay/Lists/Posts/Post.aspx?List=8668452e%2D7252%2D4550%2Da3cc%2D4674f95c47f5&ID=20&Web=fe6458d0%2De74c%2D41ff%2D90e5%2Dc802343332fb 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.