INTRODUCTION
Microsoft Power Pages is a platform for developing web sites - from very simple... to surprisingly complex. However, with additional complexity comes the need to leverage external JavaScript libraries. We'll be taking a look at that in this brief article.
ASSUMPTIONS
This article will be most useful to you if you already have some working knowledge of
- Power Pages platform
- Creating a Site and Adding Pages/Components
- HTML
- Specifically, the Script tag
- Portal Management
- All of the information surrounding a Power Pages site is stored in a D365 environment and that data is accessible through the D365 Portals application
<div class="row sectionBlockLayout text-left" style="display: flex; flex-wrap: wrap; margin: 0px; min-height: auto; padding: 8px;">
<div class="container" style="padding: 0px; display: flex; flex-wrap: wrap;">
<div class="col-md-12 columnBlockLayout" style="flex-grow: 1; display: flex; flex-direction: column; min-width: 310px; word-break: break-word;">
<div class="mb-3" id="body">
<label for="editor">Dashboard Message</label>
<textarea id="welcomeContent" style="width:100%;"></textarea>
</div>
</div>
</div>
</div>
- click the Edit code button to open Visual Studio Code for Web.
- click the JavaScript file on the left explorer panel
- this loads the file in the editor
- The following code will dynamically load the Jodit JS/CSS from the CDN
- This code will initialize the editor
let welcomeEditor = null;
var joditCSS = document.createElement("link");
joditCSS.rel = "stylesheet";
joditCSS.type = "text/css";
joditCSS.href = "//cdnjs.cloudflare.com/ajax/libs/jodit/3.19.3/jodit.min.css";
document.getElementsByTagName("head")[0].appendChild(joditCSS)
let joditScript = document.createElement("script");
joditScript.type = "text/javascript";
joditScript.src = "//cdnjs.cloudflare.com/ajax/libs/jodit/3.19.3/jodit.min.js";
document.head.appendChild(joditScript);
document.addEventListener("DOMContentLoaded", function(){
console.log("initRegistrations started");
document.getElementById('email').addEventListener(
'change',
email_Change
);
document.querySelectorAll('.fldRequired').forEach(c => {
c.addEventListener('change', event => {
validateRequired(c);
});
});
setTimeout(() => {
document.querySelectorAll('.fldRequired').forEach(c => {
validateRequired(c);
});
}, 1000);
welcomeEditor = Jodit.make("#welcomeContent");
});
- Is this library used by other pages?
- Get a local copy and use Method 1
- Is this library available from a CDN
- Consider Method 2
- Are the timing issues with the load of the files?
- Use Method 1

No comments:
Post a Comment