|
Options
OptionsThe various options for ajaxify: appendString. Appends the specified string to the end of the URL, useful for handling the page differently (stripping header and footer). Deafult: 'ajax=1' buttonsString. The jQuery selector used to find the submission methods. Default: 'button[type=submit], input[type=submit], input[type=image]' confirmMixed. If set to a string, will be displayed in a confirm() box before proceeding with the request. If set to any non-true value, will proceed normally. Default: null replaceBoolean. If set to true, will replace() content in the update element, otherwise will just append(). Default: true submitObject. Various events to be carried out onsubmit. disableObject. Disable certain elements (form only) selector String. If set, will disable all elements within the parent element that match the selector, if set to the string 'buttons' will use the same selector as the buttons option, if set to any non-true value, no elements will be disabled. Default: null className String. If set to a non-empty string, will apply the specified class to the elements specified by the selector option. Default: null messageObject. Display a message when the onsubmit event is fired. text String. If set to a non-empty string, will apply display the string as a message on the screen. Note: currently this message is appended to the <body/> in a <div/> that is given the id ajaxify__submitMessage__ Default: null className String. If set to a non-empty string, the specified class is applied to the message box. Default: null waitingObject. If nothing has happened after waiting.timeout * 1000ms, update the message (if set) and re-enable the buttons (if disabled). timeout Number. The duration (in seconds) to wait before un-doing the submission events. If set to any non-true value, this will not run. Default: 0 message String. The updated message. If set to a non-true value, the message will not be changed. Default: null className String. An updated class to apply to the message box. Default: null callback Function. A callback run when the timeout is reached. Default: null updateMixed. The element to populate with the returned data, or a selector for the specified element. If this is set to a non-true value, the container element will be checked for a target attribute, if this is found it will be used, if it's not found, the container's parent node will be used. Default: null jQuery AJAX object optionsYou can also pass options for the jQuery AJAX object to the ajaxify() method. See http://docs.jquery.com/Ajax/jQuery.ajax#toptions. asyncDefault: true beforeSendDefault: null completeDefault: null contentTypeString. If set to a non-true value, the enctype attribute will be checked (<form/>) or 'application/x-www-form-urlencoded' will be used (<a/> or no enctype attribute set). Default: null dataFilterDefault: null dataTypeDefault: 'html' errorDefault: function(XHR, textStatus, errorThrown) {
// to access the options you can use var options = this; or see the success function for alternative is this changes in future
if ('console' in window) {
if ('warn' in window.console) {
console.warn('Error processing data via AJAX:\n' + errorThrown + ' (' + textStatus + ')');
} else if ('log' in window.console) {
console.log('Warning: Error processing data via AJAX:\n' + errorThrown + ' (' + textStatus + ')');
}
} else {
alert('Error processing data via AJAX:\n' + errorThrown + ' (' + textStatus + ')');
}
}successDefault: function(data, textStatus) {
// this refers to this options object, when I assumed it would refer to the AJAX object, will this change in future versions?
var options = this;
// if it does change in the future, then this snippet should help:
// if (this.id) {
// var options = Ajaxify.retrieve(this.id).options;
// }
if (options.replace) {
jQuery(options.update).html(data);
} else {
jQuery(options.update).append(data);
}
}typeString. If set to a non-true value, the container element will be checked for a method attribute (<form/>) or will be set to 'GET' (<a/>). Default: null urlString. If set to a non-true value, the container element will be checked for an action attribute (<form/>) or an href attribute (<a/>) and this will be used. Default: null |