| Hello kind readers…
Lately we had a requirement where we wanted to do some JavaScript and CSS tricks when the page was in edit mode…. Now for this we needed to check if currently the page was in Edit Mode… now there are couple of ways of doing this using the object model or Client object model … but adding extra code processing just for a simple requirement was something I was not feeling good about…. So I cracked open page html source … the best place to find info what SharePoint already renders… Some time back I did a post on useful variable in SharePoint 2010 … but yet there are more and it is one of the JavaScript variables that came to my rescue…
So cutting it short… basically there is a JavaScript variable g_disableCheckoutInEditMode which is present on the page by SharePoint 2010 which is set to False when page is in checked in mode ... and the moment you check out the page for edit this variable is set to True by SharePoint itself when the page is rendered… so now since the information was already present on the page .. No need for any extra calls and a simple way to do was…
If(g_disableCheckoutInEditMode) { //Do some client side JQuery logic as page is in Edit mode } Else { //Do some logic when page is in checked in mode }
So you can easily do some customization when you want to do some client side scripting based on page edit mode… you can easily call some Client object model code also from here in case you want to so particular operations… reasons can be plenty…
Hope this is useful to someone in some way!!
-"T"
|