I created a form popup that grows with a hidden trigger on the mouseleave page. Thus, I performed a full check of the entered values, and then with ajax data went to php to send an email. Before that, everything was fine. Now I need to remove the html content from index.html and add it from an external file, for example, with the name form.html. I decided to use an iframe, so I managed to create the form as a pop-up window, but form validation or entered values ββare no longer performed. I am using an old version of fancybox, not version no2. All controls where jQuery selectors are stored, etc., Now even the Submit button is not recognized. Then I thought about the on () function, so I wrote
$("#submit").on('click', function() { ... });
But nothing of the kind. Any ideas? Maybe I don't need to use iframe, but ajax to load the content and then on (). I tried this too, but I had problems with a form of pop-up content that could not display normally.
That is all I have done so far.
$(document).ready(function(){ 'use strict'; //Bring form.html content with ajax into the page $('body').append('<a id="trigger" href="#form_id"></a>'); //Check for mobile device, if jQuery.browser.mobile is false then we have a desktop or a laptop if(!jQuery.browser.mobile) { //Popup is triggered when mouseleave effect happens $(document).mouseleave(function() { 'use strict'; //Check if cookie popup already exists var popupCookie = COOKIE.getCookie('popup'); //If it is then popup doesn't show if(!popupCookie) {//Popup appears but a popup cookie is set with duration set to 24 hours from now //Set expiration limit in 24 hours var expire = new Date(); var time = expire.getTime(); time += 24 * 3600 * 1000;//Exactly 24 hours from now expire.setTime(time); //Set a popup cookie COOKIE.setCookie('popup', 'popup', expire); $("#trigger").fancybox(); //Triggers popup $("#trigger").trigger('click'); $.ajax({ url: "form.html", success: function(data){ $('body').append(data); } }); //Reset values $('input:text').val(''); $('textarea').val(''); $('
source share