Stratox
Stratox
Stratox
  • Why Stratox
  • Installation
  • Quick Start (MVC)
  • Views / components
    • Layout & Components
    • Update components
    • Component argumnets
  • Features
    • Styled components
    • Events
    • Services
    • Fetch Library (Ajax Requests)
  • Router
    • Routes and URI
    • Dispatch States (navigate)
    • Dispatcher overview
  • Deployment
    • Deployment Guide
  • Step by step tutorial
    • Directory overview
    • Getting started
    • Navigation
    • Controllers
    • Increment / Events
    • Form Builder
    • Building Modal
  • Stratox Tailwind
    • Design system
  • Configs
    • Index
    • Configs
    • Response Arguments
Powered by GitBook
On this page
  • Config example
  • fields
  • helper
  • ready
  • request (Fetch API library / ajax)
  1. Configs

Configs

Config example

I will explain every config bellow the example.

const app = new App({
    fields: Fields, 
    helper: function() {
        // The Helpers of your choice will be passed to the controllers, views and components
        return {
            yourHelper1: {},
            yourHelper2: {}
        };
    },
    ready: function(builder, observer) {
        //const inst = this; // Stratox main instance
    },
    request: { // Enable Ajax
        dataType: "json",
        url: "https://example.se/backend-location/",
        path: '/api',
        startPath: "home",
        config: {
            headers: {
                'Accept': 'application/json'
            }
        },
        get: function(searchParams) {
            searchParams.append("param", 1);
            return searchParams;
        },
        post: function(object) {
            object.param = 1;
            return object;
        }
    }
});

fields

Fields are loaded by default in the main.js file. You can customize the Fields file "./src/templates/Fields.js" or create a new one. This file contains elements such as form fields and is utilized by the form builder. Note that the form builder will not function without the components. However, if your application does not utilize any forms, you can manage without it. In such cases, you can remove fields from the configuration entirely, thereby reducing the size of your application.

helper

The helper config allows you to pass all third-party library functions to your routes, controllers, views, and components. This enables you to easily utilize these functions by initializing them in one central location and then distributing them throughout the app.

The helper config accepts any data type, but it's highly recommended to structure it as a function that returns an object containing the expected libraries, like bellow.

helper: function() {
    return {
        yourHelper1: {},
        yourHelper2: {}
    };
}

ready

This will be triggered once the main Startox view has finished loading.

request (Fetch API library / ajax)

  • url: The URL to your site/API location to access via Ajax.

  • dataType: Set expected response data type json, xml or text. Json response will be converted to object, xml to DOMParser and text will be text. (default: json)

  • path: Extends the URL with a URI path. (optional)

  • startPath: Adds a default start path if the URI path is empty. (optional)

  • get: Passes custom or modifies a GET parameter for the controller result. (optional)

  • post: Passes custom or modifies a POST parameter for the controller result. (optional)

PreviousIndexNextResponse Arguments

Last updated 7 months ago

Read more about ajax in the section.

config: Supplies the fetch request with options. You can read more about these options . (optional)

Ajax Integration
here