Simplemodal AJAX
I'm trying to implement Simplemodal on my website. Simple text boxes are really easy to do, but I can't find a way to have another page showing through AJAX. I know very little about Jquery and there is no documentation on how to do it, so could somebody help me? Thanks.
This is the default code of a Simple Modal box:
jQuery(function ($) {
$('#basic-modal .basic').click(function (e) {
$('#basic-modal-content').modal();
return false;
});});
This is some code I took from the Simple Modal contact form that works with AJAX. I've been trying to tweak it but I don't really understand the structure of it. As I said, I'm completely new to Jquery.
$.get("data/contact.php", function(data){
开发者_开发百科 // create a modal dialog with the data
$(data).modal({
closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
position: ["15%",],
overlayId: 'contact-overlay',
containerId: 'contact-container',
onOpen: contact.open,
onShow: contact.show,
onClose: contact.close
});
});
});
i can't see exactly the problem is without fully code of your page.
how about change this code :
$(data).modal({
to be :
$('#basic-modal-content').modal({
after this line:
$.get("data/contact.php", function(data){
before this line:
$('#basic-modal-content').modal({
write this code :
$('#basic-modal-content').html(data);
I am new in jQuery too and, I believe, the way you have it would not work since "data" even though could have been served by your php as a div, a paragraph, etc, it does not exist as of yet. Therefore, you could not be modal-ed, ... I think.
However, though, you could load that data into a hidden div and modal it:
$('#myDiv').html(data); $('#myDiv').modal();
精彩评论