Configuration - dougflip/BladeJs GitHub Wiki
BladeJs exposes default properties and delegates which can be overridden and handled by your application. These configuration items should be set during document ready of your page. This provides an easy way to set global callbacks and settings. The values provided to the $.fn.blade.defaults
object will always be assumed when nothing more specific is provided. This allows you to exclude these values from your markup once they are registered with BladeJs.
$(function(){ $.fn.blade({ ajaxSuccess: ajaxSuccess_Default, log: logToConsole }); });
The default function to be invoked whenever an ajax request fails (receives a 500 response). Individual requests can provide specific error functionality by providing a value to data-blade-error
. The base implementation, provided by BladeJs, simply attempts to log the error via $.fn.blade.defaults.log
The default function to be invoked whenever an ajax request succeeds. Individual requests can provide specific functionality by providing a value to data-blade-success
. The base implementation, provided by BladeJs, simply attempts to log the success via $.fn.blade.defaults.log
.
Typically you will provide your most basic update strategy to this function. For example, you may instruct BladeJs to simply replace content matched by a selector with the returned response. In this case you only need to specific data-blade-success
for interactions that require special logic.
Corresponds to jQuery beforeSend handler. If present this function will be invoked before every ajax request. Individual requests can provide specific functionality by providing a value to data-blade-before-send
. There is no default implementation.
Default function to be executed when an action requires user confirmation, data-blade-confirm
.
Default implementation simply shows a browser confirm window before sending the request to jQuery.
This function will be invoked anytime BladeJs needs to log an event/error. Override to allow BladeJs access to your own logging implementations. Default implementation simply attempts to log information to the browser console log (if one is available).