Финал: Ajax/jQuery/PHP. Представление формы и модальная коробка открыта на успехеJquery

Программирование на jquery
Ответить
Anonymous
 Финал: Ajax/jQuery/PHP. Представление формы и модальная коробка открыта на успехе

Сообщение Anonymous »

случай: http://santz.net/index.contacto.html
цель: «Веб -сайт» должен открыть диалог/модальное окно/модальное окно после успешной формы. Окно не открывается (редко, оно открывается, если вы делаете еще один щелчок ...) < /p>
Идея довольно проста! Когда пользователь представляет форму, диалог мгновенно появляется!











Mensaje













скрипт и прикрепленные сценарии







$(function() {
$('#contact-form').submit(function() {
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(),
success: function() {
$('#popup-wrapper').modalPopLite({
openButton: '#clicker',
closeButton: '#close-btn'
});
}
});
$('#contact-form')[0].reset();
return false;
});
});


Скрипт модального ящика (тот, который поставлялся с плагином, который я использую: http://mywebdeveloperblog.com/my-jquery ... dalpoplite)
>>(function ($) {
var popID = 0;
$.fn.modalPopLite = function (options) {
var options = $.extend({}, { openButton: "modalPopLite-open-btn", closeButton: "modalPopLite-close-btn", isModal: false, callBack: null }, options);

return this.each(function () {
popID++;
var thisPopID = popID;
var isOpen = false;

obj = $(this);
triggerObj = options.openButton;
closeObj = options.closeButton;
isReallyModel = options.isModal;

//alert("winH: " + winH + "top: " + top + "objH: " + objH);
obj.before('');
obj.wrap('');
obj.addClass('modalPopLite-child-' + thisPopID);

$(triggerObj).live("click", function (e) {
e.preventDefault();
var winW = $(window).width();
var winH = $(window).height();
var objW = $('.modalPopLite-child-' + thisPopID).outerWidth();
var objH = $('.modalPopLite-child-' + thisPopID).outerHeight();
var left = (winW / 2) - (objW / 2);
var top = (winH / 2) - (objH / 2);

$('#modalPopLite-mask' + thisPopID).css('height', winH + "px");
$('#modalPopLite-mask' + thisPopID).fadeTo('slow', 0.6);
//$('#modalPopLite-wrapper' + thisPopID).hide();
$('#modalPopLite-wrapper' + thisPopID).css({ 'left': left + "px", 'top': top });
$('#modalPopLite-wrapper' + thisPopID).fadeIn('slow');
isOpen = true;
});

$(closeObj).live("click", function (e) {
e.preventDefault();
$('#modalPopLite-mask' + thisPopID).hide();
//$('#modalPopLite-wrapper' + thisPopID).hide();
$('#modalPopLite-wrapper' + thisPopID).css('left', "-10000px");
isOpen = false;
if (options.callBack != null) {
options.callBack.call(this);
}
});

//if mask is clicked
if (!isReallyModel) {
$('#modalPopLite-mask' + thisPopID).click(function (e) {
e.preventDefault();
$(this).hide();
//$('#modalPopLite-wrapper' + thisPopID).hide();
$('#modalPopLite-wrapper' + thisPopID).css('left', "-10000px");
isOpen = false;
if (options.callBack != null) {
options.callBack.call(this);
}
});
}
$(window).resize(function () {
if (isOpen) {
var winW = $(window).width();
var winH = $(window).height();
var objW = $('.modalPopLite-child-' + thisPopID).outerWidth();
var objH = $('.modalPopLite-child-' + thisPopID).outerHeight();
var left = (winW / 2) - (objW / 2);
var top = (winH / 2) - (objH / 2);
$('#modalPopLite-wrapper' + thisPopID).css({ 'left': left + "px", 'top': top });
}
});
});

};

$.fn.modalPopLite.Close = function (id) {
$('#modalPopLite-mask' + id).hide();
//$('#modalPopLite-wrapper' + id).hide();
$('#modalPopLite-wrapper' + thisPopID).css('left', "-10000px");
if (options.callBack != null) {
options.callBack.call(this);
}
};

$.fn.modalPopLite.ShowProgress = function () {
$('').appendTo("body")
};

$.fn.modalPopLite.HideProgress = function () {
$('.popBox-ajax-progress').remove();
};

})(jQuery);

php


alert('Gracias por contactarse, en breve, me pondre en contacto.\n\nSantz Design | www.santz.net');
window.location = 'index.contacto.html';



alert('El envio fallo. Por favor, envie un mail directamente a info@santz.net');
window.location = 'index.contacto.html';




Подробнее здесь: https://stackoverflow.com/questions/152 ... on-success
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»