-
Notifications
You must be signed in to change notification settings - Fork 12
MicroApp Dev: JavaScript Helper Functions
These functions (callable by app.______
), are available within your app's local context, and can be helpful in providing basic interactivity and other standard functionality within your app.
Note: While app.data
is available most everywhere, the app
helper functions mentioned in this document are only available within the context of the this.callback
function. Please ensure that you have defined a this.callback
function to ensure full access to the functions below.
Table of Contents |
---|
app.click |
app.get |
app.post |
app.put |
app.delete |
app.refresh |
app.update |
app.form |
app.grid |
app.alert |
This function registers a callback which is triggered when a user clicks on a DOM element matching the specified selector.
Argument | Type | Description |
---|---|---|
selector | String | This is the CSS selector string which maps to the element that should trigger a click event |
callback | Function | This is the function that is called when the click event is triggered |
This function performs an AJAX request to a resource using the HTTP 'GET' verb.
Argument | Type | Description |
---|---|---|
resource_name | String | This is the name of the resource as defined in the micro app definition |
data | Object | This is an object which contains the data to be sent. (Data is encoded as a standard URI "query" as part of the request) |
callback_success | Function | This is the function which will be called upon success (HTTP "200" Response Code) |
callback_failure | Function | This is an optional which will be called upon failure (Non "200" Response Code) |
This function performs an AJAX request to a resource using the HTTP 'POST' verb.
Argument | Type | Description |
---|---|---|
resource_name | String | This is the name of the resource as defined in the micro app definition |
data | Object | This is an object which contains the data to be sent. (Data is encoded as x-www-form-urlencoded data as part of the request. The "x-www-form-urlencoded" header is sent as part of the request.) |
callback_success | Function | This is the function which will be called upon success (HTTP "200" Response Code) |
callback_failure | Function | This is an optional which will be called upon failure (Non "200" Response Code) |
This function performs an AJAX request to a resource using the HTTP 'PUT' verb.
Argument | Type | Description |
---|---|---|
resource_name | String | This is the name of the resource as defined in the micro app definition |
data | Object | This is an object which contains the data to be sent. (Data is encoded as x-www-form-urlencoded data as part of the request. The "x-www-form-urlencoded" header is sent as part of the request.) |
callback_success | Function | This is the function which will be called upon success (HTTP "200" Response Code) |
callback_failure | Function | This is an optional which will be called upon failure (Non "200" Response Code) |
This function performs an AJAX request to a resource using the HTTP 'DELETE' verb.
Argument | Type | Description |
---|---|---|
resource_name | String | This is the name of the resource as defined in the micro app definition |
data | Object | This is an object which contains the data to be sent. (Data is encoded as x-www-form-urlencoded data as part of the request. The "x-www-form-urlencoded" header is sent as part of the request.) |
callback_success | Function | This is the function which will be called upon success (HTTP "200" Response Code) |
callback_failure | Function | This is an optional function which will be called upon failure (Non "200" Response Code) |
This function completely refreshes the application. This includes refetching / initializing the data, and redrawing all templates, etc. This function accepts no parameters.
This function updates the app data object, and instructs the template rendering engine to re-render the templates (with updated data). This function should be called whenever the app data object is updated. Optionally, this function may accept parameters which will directly update the app data object.
Argument | Type | Description |
---|---|---|
data | Object | This is an optional data object which will be merged into the existing app data object, and serves as an easy way to update the app data object without performing an additional external assignment |
This function instantiates and returns an instance of the GrapheneForms form as defined in Micro App "Forms" tab, and optionally binds to a specified DOM element. Subsequent calls to app.form with the same form name will return the same form which was previously instantiated. Once a form has been bound to an element, it cannot be rebound to a different element without first destroying the form.
Argument | Type | Description |
---|---|---|
form | String / Object | This required field is either the name of a form (as defined in the Micro App "Forms" tab, or a GrapheneForms object definition. |
selector | String | This optional field is a "css selector" to a given DOM element contained within the Micro App. Example: "#my-form" |
This function instantiates and returns an instance of the GrapheneDataGrid grid.
Argument | Type | Description |
---|---|---|
name | String | This required field is the name of a grid |
options | Object | This required field contains the options for configuring your GrapheneDataGrid |
This function initiates a temporary popup alert based on the options supplied.
Argument | Type | Description |
---|---|---|
options | String / Object | This required field is either an alert String or Object which configures the alert. |
options.title | String | Title affiliated with the alert |
options.content | String | Body affiliated with the alert |
options.status | String | Color of the alert: (info, warning, error, success) |