Today I show you a way to create custom triggers in case you need to trigger events dependent on others, perhaps not editable.
An example of utility is when you find yourself with external ajax calls or events not covered so you must still identify the moment of conclusion.
A couple of examples of the possibilities:
1) I show an alert when an ajax has loaded (in our case a test page):
$.when( $.ajax( "test.php") ).then(function(data, textStatus, jqXHR) {
alert( jqXHR.status ); // Alerts 200
});
2) I show an alert to the valorization of a variable:
$.when( { testing: 123 } ).done(function( x ) {
alert( x.testing ); // Alerts "123"
});
In our example, the variable is valued immediately but could be returned by an ajax call to which the event could be triggered.