Fala Pessoal!
Estou tentando usar prototype do js para modificar o evento onClick de um botão de salvar, este evento já funciona em vários casos e fazer parte do framework interno que usamos, porém neste caso preciso executar uma ação após a execução do evento mas não quero adicionar um linha a mais no fonte da rotina, como fazer isso?
Segue código:
$('button[data-form]').on('click', function(){
var btn = $(this);
var href = btn.attr('data-form').replace(/\{0\}/g, btn.attr('data-select'));
$('body').modalmanager('addLoading');
$.ajax({
url: href,
dataType: 'html',
success: function(data) {
var json = undefined;
try {
json = eval('(' + data + ')');
} catch(e) {
}
if (json && json.type == 'ERROR') {
$.error(json.message);
} else {
var $modal = $('.modal:has(form[data-modal-form])');
var form = $modal.find('form');
var index = form.parents('div[data-table]').find('table[data-table][data-table-index]').attr('data-table-index');
var $modalBody = form.attr('data-table-index', index).find('.modal-body');
$modalBody.html(data.replace(/td>\s+<td/g,'td><td'));
$modalBody.prepend(alertDiv.addClass('hide'));
$modal.off('shown').on('shown', function(){
form.find('input[type="text"]:enabled:not([readonly="readonly"]):first').focus();
if ((typeof initChosen) !== 'undefined')
initChosen();
form.find(':input[data-value]').each(function() {
var $this = $(this);
var value = $this.data('value');
var multiple = $this.is('select[multiple]');
if (multiple)
value = value.split(',');
$this.val(value);
if ($this.is('select:not(.no-chosen)'))
$this.trigger('chosen:updated');
});
});
$modal.modal();
}
},
complete: function() {
$('body').modalmanager('removeLoading');
}
});
});
Gostaria de saber se de alguma maneira consigo executar algo a mais com prototype sem alterar esta rotina