Skip to main content
Skip table of contents

CB_PORTAL interface

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

CB_PORTAL.selectPage

CODE
Used in parsers to change the page programmatically   

CB_PORTAL.toggleFlyout

CODE
Used in parsers to open and close flyout panes programmatically   

CB_PORTAL.getPathParams

CODE
Used in parsers to get information on URL path variables

CB_PORTAL.ClearBlade

CODE
Used in parsers to interact with the underlying ClearBlade JavaScript API

CB_PORTAL.registerDatasource

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

CB_PORTAL.registerWidget

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

CB_PORTAL.portalModel

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

CB_PORTAL.toggleFlyout()

CODE
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)

CODE
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
CODE
// 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)

CODE
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
CODE
CB_PORTAL.Loader.hide('myBtn')

CB_PORTAL.Loader.waitFor(promise, htmlId)

CODE
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:

CODE
var myPromise = new Promise(
  (resolve) => setTimeout(() => resolve('done'), 1000)
)

CB_PORTAL.Loader.waitFor(
  myPromise
)

Real-world example:

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

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.