In Elements.xml file of App Part, append editMode token to Src attribute of Content tag
Note: _editMode_ token will be replaced automatically by 0 or 1 depending on the current mode.
Add following helper function in App Part Page to retrieve the parameters from query string.
Note: _editMode_ token will be replaced automatically by 0 or 1 depending on the current mode.
<Content Type="html" Src="~appWebUrl/Pages/ClientWebPart1.aspx?{StandardTokens}&editMode=_editMode_" />
Add following helper function in App Part Page to retrieve the parameters from query string.
function getQueryStringParameter(paramToRetrieve) {
var params;
var strParams;
params = document.URL.split("?")[1].split("&");
strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve)
return decodeURIComponent(singleParam[1]);
}
}
Use following code to detect current mode.
var editMode = getQueryStringParameter("editMode");
if (editMode == "1") {
alert("editMode");
} else {
alert("displayMode");
}
No comments:
Post a Comment