I have a Magnific Popup page:
function dataLink(){
$.magnificPopup.open({
items: {
src: 'datapage.html',
type: 'ajax'
},
closeOnContentClick : false,
closeOnBgClick :true,
showCloseBtn: false,
enableEscapeKey : false,
callbacks: {
open: function(){
$.magnificPopup.instance.wrap[0].addEventListener('focus', mpTable);
},
close: function(){
$.magnificPopup.instance.wrap[0].removeEventListener('focus', mpTable);
},
}
});
}
datapage.html has two tables, that I hide or show depending on the context (page is loaded with data1table showing and data2table hidden):
<div class="white-popup">
<table id="data1table" class="table1">
</table>
<table id="data2table" class="table2">
</table>
</div>
Within table1 there is a button that hides table1 and shows table2. In table2 there is a button that calls a javascript function to send data:
<input onclick="dataCheck()" type="button" value="Check Data" />
which then calls:
function dataCheck(){
if(datacheck[0]==false || datacheck[1]==false){
alert("Please enter data in all fields correctly.");
} else{
$.ajax({
url: 'dataconfirm.php',
type: "POST",
async: false,
data: {
},
dataType: 'json',
success: function(data){
alert("Thank you!");
localdata=data;
$.magnificPopup.close();
}
});
};
}
My challenge is that when you click on the button to call dataCheck(), it reverts to showing table1 (as originally loaded by Magnific Popup) and in fact doesn't event call dataCheck(). If the user clicks again on the button to show table2, they can then click the button for dataCheck() a second time, and it works fine. Thanks for any ideas- I am at a loss as to why this is happening, especially given that it works the second time around.