Skip to content

Instantly share code, notes, and snippets.

@eduardo-matos
Last active December 14, 2015 19:08
Show Gist options
  • Save eduardo-matos/5134138 to your computer and use it in GitHub Desktop.
Save eduardo-matos/5134138 to your computer and use it in GitHub Desktop.
Disparando eventos com jQuery
function CentralDeProdutos () {
$(this).on('adicionado', function (evt, sucesso) {
alert('Removido com sucesso: ' + sucesso);
});
$(this).on('removido', function (evt, sucesso, numeroProdutosRemovidos) {
alert('Removido com sucesso: ' + sucesso);
alert('Número de produtos removidos: ' + numeroProdutosRemovidos);
});
}
CentralDeProdutos.prototype.add = function () {
$(this).trigger('adicionado', [true]);
}
CentralDeProdutos.prototype.remove = function () {
$(this).trigger('removido', [true, 3]);
}
var central = new CentralDeProdutos();
central.add();
central.remove();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment