4
I have an event where a modal is displayed, in it I want to call a function validateEmail
but I can’t.
validateEmail: function(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
},
events: {
'onSwitchChange #servicos input.switch': function (evt) {
(...)
},'onSwitchChange #users input.switch' : function(evt){
(...)
},
'click #UserView button#viewas': function (evt) {
(...)
}, 'click button#update' : function(evt){
evt.stopImmediatePropagation();
var $me = $(evt.currentTarget);
var tpl = Handlebars.compile($("#tpl-instancia-edit").html());
var cat = $me.data('categoria');
var dono = $me.data('dono');
var id = $me.data('id');
var $modal = $(tpl()).modal();
$modal.show(function (evt){
(...)
});
$modal.on('click', '#salvar', function(){
evt.stopImmediatePropagation();
//chamar funcao aqui
alert(this.validateEmail($('input[id=donoUpdate]').val()));
(...)
}
});
});
},
[SOLVED]Just declare the function within the event
– Daniela Morais
You can post this as an answer?
– Laerte