Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Last active August 29, 2015 14:15
Show Gist options
  • Save wescleymatos/3bfc261c3cca1fbfb5e4 to your computer and use it in GitHub Desktop.
Save wescleymatos/3bfc261c3cca1fbfb5e4 to your computer and use it in GitHub Desktop.
Exemplo simples de Custom Event
var event = new CustomEvent('build', {
'detail': 'wescley'
});
document.addEventListener('build', function(e){
alert(e.detail);
var nome = e.detail + ' matos';
var ajaxEvent = new CustomEvent('ajax-return', {
'detail': nome
});
document.dispatchEvent(ajaxEvent);
});
document.addEventListener('ajax-return', function(e){
alert(e.detail);
});
document.dispatchEvent(event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment