several dynamic simplemodal boxes
I'm developing a website where user's can create calendars and then add events to them. One of my pages lists out all the calendars the user has created. I would like a "Delete" link next to each calendar title and have a simplemodal box pop up so they confirm they intend to delete the calendar along with all it's associated events. I need to append the calendar_id number to the jquery somehow to make sure the correct modal box pops up with the right "Yes, Delete" link. I was going to just append the calendar_id to the #basic-modal and #basic-modal-content id names, but the CSS wouldn't match up.
Another thing i think i could do somehow is just pass the right "Yes, Delete" link into the modal boxes with a function. But i have no idea how to inject the html in the modal box.. something like this...
function getsimplemodal(X){
$('#basic-modal .basic').click(function (e) {
var delete_link = "http://mysite.com/delete.php?cal_id=" +X;
--code to inject delete_link into the modal box--
$('#basic-modal-content').modal();
return false;
});};开发者_Go百科
Does anyone know how in the world i could do this?
Tried the code below to test if i could append anything to it but it broke the code. Nothing displayed. It display if i remove the .append line.
jQuery(function ($) {
// Load dialog on page load
//$('#basic-modal-content').modal();
// Load dialog on click
$('#basic-modal .basic').click(function (e) {
("#basic-modal-content").append("<strong>Testing</strong>");
$('#basic-modal-content').modal();
return false;
});
});
figured it out!
i wrote a function to use onclick of my links.
function confirmCalendar(X) {
$('#basic-modal-content').modal();
var delete_link = "<a href='http://localhost:8888/calendars/index.php/edit_calendar/delete/" + X + "'>Yes, Delete</a> ";
$('#modal-p').prepend( delete_link );
return false;
};
and then my hidden #basic-modal-content
<!-- modal content -->
<div id="basic-modal-content">
<h3>Are you sure you want to delete this calendar and all its associated bookings?</h3>
<p id="modal-p"> or <a href='#' class='simplemodal-close'>Cancel</a></p>
</div>
and then for my dynamic links
echo "<a href='#' onclick='confirmCalendar($row->id);'>Delete</a>";
code to inject:
$("#basic-modal-content").append("<a href=" + delete_link + "> Delete </a>");
精彩评论