Skip to content

Configuration

Kwasi Yonkopa edited this page Jul 19, 2019 · 6 revisions

Config & Initialization

Below are the available options and their default values for configuring Dash.

{
    // {Boolean} When set to true reloads the app content after a successful return of `Dash.resources.create`
    autoReload: false,

    // {String} CSS selector for the app content wrapper
    content: '#content',

    // {String} CSS selector of active form i.e A selector that will match the form that is currently being edited
    activeForm: null,

    // {String} Base API endpoint e.g. https://your-app.com/api/v1
    baseResourceURL: null,

    // {Object} Default headers to be passed with every request/API call
    requestHeaders: {},

    // {Boolean} This when set to true will trigger a click on the first item in your view anchor  NodeList i.e. the first link in your app menu
    triggerInitialViewFetch: false,

    // {String} General CSS selector for your view anchors / app menu
    viewSelector: '.view-anchor',

    // {String}  CSS selector for reload button i.e. button to reload your dashboard/app content...
    // only leaving menu and other static components intact.
    reloadSelector: '.reload',

    // {Boolean} Temporarily turns off automatic app reload after a successful resource ajax request
    // sets to false after request.
    tempOffAutoReload: false,

    // {Boolean}  Enable history manipulation feature
    history: false,

    // {String}  Application home URL eg. https://your-app.com/dashboard || https://your-app.com/home
    appURL: window.location.href
}

To configure your application, initialize DashJS passing configuration options as an object

Dash.init({
    autoReload: true,
    content: '.view-item'
});

Note that you do not need to pass any options to Dash.init() if you're fine with the defaults. Just initialize before any DashJS specific code as shown below.

Dash.init();

Clone this wiki locally