Class XataJax.actions
Defined in: xatajax.actions.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Utility functions for dealing with actions and selected actions.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
XataJax.actions.ConfirmCallback(recordIds)
A callback function that can be passed to doSelectedAction() to serve as
a confirmation to the user that they want to proceed with the action.
|
| <static> |
XataJax.actions.doSelectedAction(params, container, confirmCallback, emptyCallback)
Performs an action on the currently selected records in a container.
|
| <static> |
XataJax.actions.getSelectedIds(container, asString)
In a result list with checkboxes to select record ids, this gets an array
of the recordIds of the checked records (or a newline-delimited string).
|
| <static> |
XataJax.actions.handleSelectedAction(aTag, selector)
Handles a selected action that was triggered using a given link.
|
| <static> |
XataJax.actions.hasRecordSelectors(container)
Checks to see if the given element contains any selector checkboxes for selecting records.
|
Method Detail
<static>
{Boolean}
XataJax.actions.ConfirmCallback(recordIds)
A callback function that can be passed to doSelectedAction() to serve as
a confirmation to the user that they want to proceed with the action.
- Parameters:
- {Array} recordIds
- An array of record ids that are to be acted upon.
- Returns:
- {Boolean} true if the user confirms that they want to proceed. False otherwise.
<static>
{void}
XataJax.actions.doSelectedAction(params, container, confirmCallback, emptyCallback)
Performs an action on the currently selected records in a container.
Note that the selected IDs will be sent to the action in the --selected-ids POST parameter. One record ID per line. See df_get_selected_records() PHP function to load these records.
// This will perform the my_special_action action on all selected records in
// the result_list section of the page. It looks through the checkboxes.
XataJax.actions.doSelectedAction({
'-action': 'my_special_action'
},
jQuery('#result_list'),
function(ids){
return confirm('This will perform my special action on '+ids.length+' records. Are you sure you want to proceed?');
}
});
- Parameters:
- {Object} params
- The POST parameters to send to the action.
- {HTMLElement} container
- The container that houses the checkboxes.
- {XataJax.actions.ConfirmCallback} confirmCallback
- Optional callback function that can be used to prompt the user to confirm that they would like to proceed.
- {Function} emptyCallback
- Callback to be called if there are no records currently selected.
- Returns:
- {void}
<static>
{mixed}
XataJax.actions.getSelectedIds(container, asString)
In a result list with checkboxes to select record ids, this gets an array
of the recordIds of the checked records (or a newline-delimited string).
This is useful for sending to Xataface actions in the --selected-ids parameter because the df_get_selected_records() function is set up to read the --selected-ids parameter and return the corresponding records.
var ids = XataJax.actions.getSelectedIds($('#result_list'), true);
$.post(DATAFACE_SITE_HREF, {'-action': 'myaction', '--selected-ids': ids}, function(res){
alert("we did it");
});
- Parameters:
- {HTMLElement} container
- The HTML DOM element that contains the checkboxes. This may be the result list table or a container thereof.
- {boolean} asString
- If false, this will return an array of record ids. If true, this will return the ids as a newline-delimited string.
- Returns:
- {mixed} Either an array of record ids or a newline-delimited string of record ids depending on the value of the asString parameter.
<static>
XataJax.actions.handleSelectedAction(aTag, selector)
Handles a selected action that was triggered using a given link. The link itself
should contain the information about the action to be performed.
- Parameters:
- {HTMLElement} aTag
- The html link that was clicked to invoke the action. The href tag for this link is used as the target action to perform - except the parameters are parsed out so that the action will ultimately be submitted via POST.
- {String} selector
- The selector to the container thart contains the checkboxes representing the selected records on which to perform this action.
<static>
{boolean}
XataJax.actions.hasRecordSelectors(container)
Checks to see if the given element contains any selector checkboxes for selecting records.
- Parameters:
- {HTMLElement} container
- The html element to check.
- Returns:
- {boolean} True if it contains at least one selector checkbox.