Answer the question
In order to leave comments, you need to log in
Doesn't fulfill Yandex .Metrics goals?
Good afternoon.
Tell me how to make the target work on the modal window, when two inputs are filled. At the moment, it works with any click on the "Submit" button.
In index.php, a js plugin is connected with the following piece of code:
* заявка на звонок
*/
$('.b-modal__send').on('click', function() {
var all = true,
$btn = $(this);
yaCounter32857735.reachGoal('zvonok');
$btn.text('Отправляем');
$btn.attr('disabled','disabled');
$('.b-modal input[type=text]').each(function(){
if(!$(this).val()) {
$(this).parent().addClass('has-error');
all = false;
} else {
$(this).parent().removeClass('has-error');
}
})
if(all) {
$.post('/ajax/email.php', { send: 'Y', name: $('#inputModalName').val(), phone: $('#inputModalPhone').val()}, function (msg) {
if (msg == 1) {
setTimeout(function() {
$btn.text('Отправлено');
$btn.addClass('btn-primary_success');
}, 300);
setTimeout(function() {
$('.b-modal').modal('hide');
}, 1300);
setTimeout(function() {
$btn.removeAttr('disabled');
$btn.text('Отправить');
$('#inputModalName, #inputModalPhone').val('');
$btn.removeClass('btn-primary_success');
}, 1400);
} else {
$btn.text('Отправить');
$btn.removeAttr('disabled');
}
});
} else {
$btn.text('Отправить');
$btn.removeAttr('disabled');
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question