Namespace: partials

partials

Helpers to manage the partials (HTML fragment).

 // Somewhere in the setup of the app
 portal.partials.rootUrl = '/content/html/';

 // Get the code of /content/html/MyFragment.html and inject it in the DOM
 portal.partials.get("MyFragment.html").then((html) => {
     const wrapper = document.createElement("div");
     wrapper.innerHTML = html;

     document.getElementById("myPlaceholder").appendChild(wrapper);
 });
Dependencies:

None

Members

(static) rootUrl :String

Root URL to get the partials HTML pages.

Type:
  • String

Methods

(static) get(url) → {Promise}

Execute an AJAX request to obtain the partials HTML

 portal.partials.get("MyFragment.html").then((html) => {
     const wrapper = document.createElement("div");
     wrapper.innerHTML = html;

     document.getElementById("myPlaceholder").appendChild(wrapper);
 });
Parameters:
Name Type Description
url String

Relative URL (from the portal.partials.rootUrl) to the partial HTML

Returns:
Type
Promise