CB_PORTAL Interface

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

CB_PORTAL.selectPage

Used in parsers to change the page 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.Loader.show(htmlId)

Used to show loader programmatically

@param {string|undefined} the html id of the element you want to show the loading icon over, if left off it will show over 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 html id of the element you want to show the loading icon over, if left off it will show over full page
CB_PORTAL.Loader.hide('myBtn')

CB_PORTAL.Loader.waitFor(promise, htmlId)

Used with a promise to automatically show and hide spinner. It will add a loader when invoked and hide it when promise resolves or errors out.

@param {Promise} the promise whose pending/resolved state will control the loader
@param {string|undefined} the html id of the element you want to show the loading icon over, if left off it will show over full page

Toy example (paste this code into the console of the portal page to see the loader for 1 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',
)