There are two javascript variables which are very helpful and are entirely free to use - I found this available on both SP 2010 and SP 2013, one all the time(_spPageContextInfo) and the other, most of the time (Ctx).
Each of these variables represents an object with lot of information related to the current context of the page.
Ctx Object :
The image shows various objects available with it. It is extremely useful on List view apps on pages.
Not available everywhere, not available on form pages(new, edit and display) and not available on layouts pages(site settings, admistration pages). not available on apps, inside lists. This object is read-only
Eg: alert(ctx.ListData.Row[2].Title);
will display the title of the third row of the list view.
_spPageContextInfo Object:
Very similar to Ctx object with minimal information than Ctx and important information about the page.
The main difference is _spPageContextInfo is available everywhere.
var _spPageContextInfo =
{
webServerRelativeUrl: "\u002f",
webLanguage: 1033,
currentLanguage: 1033,
webUIVersion:4,
pageListId:"{dc0262dd-b8fe-4d76-bd28-9125d2e115a6}",
userId:1,
alertsEnabled:true,
siteServerRelativeUrl: "\u002f",
allowSilverlightPrompt:'True'
};
The above is the variable info that was available for my page that I was on, I got it using the developer toolbar.
No comments:
Post a Comment