CB_PORTAL interface

CB_PORTAL interface

The CB_PORTAL object hangs off the window object and can be accessed in parsers.

CB_PORTAL.selectPage

Used in parsers to change the page programmatically

CB_PORTAL.toggleFlyout

Used in parsers to open and close flyout panes programmatically

CB_PORTAL.getPathParams

Used in parsers to get information on URL path variables

CB_PORTAL.ClearBlade

Used in parsers to interact with the underlying ClearBlade JavaScript API

CB_PORTAL.registerDatasource

Used by plugin files to register their definition with the portal framework

CB_PORTAL.registerWidget

Used by plugin files to register their definition with the portal framework

CB_PORTAL.portalModel

Used internally by the portal framework to store datasource and widget instances

CB_PORTAL.toggleFlyout()

This function allows the user to toggle the flyout from any parser in the portal programmatically. For example, to toggle flyout on a button, click: $('#button_id').click(function(){ CB_PORTAL.toggleFlyout(); })

CB_PORTAL.Loader.show(htmlId)

Used to show loader programmatically @param {string|undefined} the element's HTML ID you want to show the loading icon over. If left off, it will show over the full page
// targets <button id="myBtn" /> // or widget with setting 'HTML ID' set to 'myBtn' CB_PORTAL.Loader.show('myBtn') // targets the entire portal CB_PORTAL.Loader.show()

CB_PORTAL.Loader.hide(htmlId)

Used to hide loader programmatically @param {string|undefined} the element's HTML ID you want to show the loading icon over. If left off, it will show over the full page
CB_PORTAL.Loader.hide('myBtn')

CB_PORTAL.Loader.waitFor(promise, htmlId)

Used with a promise to show and hide the spinner automatically. It will add a loader when invoked and hide it when the promise resolves or errors out. @param {Promise} the promise whose pending/resolved state will control the loader @param {string|undefined} the element's HTML ID you want to show the loading icon over. If left off, it will show over the full page

 

Paste this code into the portal page’s console to see the loader for one second:

var myPromise = new Promise( (resolve) => setTimeout(() => resolve('done'), 1000) ) CB_PORTAL.Loader.waitFor( myPromise )

 

Real-world example:

CB_PORTAL.Loader.waitFor( datasources.AddBook.sendData({ title: 'a new book' }), 'create-book-btn', )

Related content