Note that there are some explanatory texts on larger screens.

plurals
  1. POseveral dynamic simplemodal boxes
    primarykey
    data
    text
    <p>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. </p> <p>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...</p> <pre><code>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; });}; </code></pre> <p>Does anyone know how in the world i could do this?</p> <p>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.</p> <pre><code>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("&lt;strong&gt;Testing&lt;/strong&gt;"); $('#basic-modal-content').modal(); return false; }); </code></pre> <p>});</p> <p>figured it out!</p> <p>i wrote a function to use onclick of my links.</p> <pre><code>function confirmCalendar(X) { $('#basic-modal-content').modal(); var delete_link = "&lt;a href='http://localhost:8888/calendars/index.php/edit_calendar/delete/" + X + "'&gt;Yes, Delete&lt;/a&gt; "; $('#modal-p').prepend( delete_link ); return false; </code></pre> <p>};</p> <p>and then my hidden #basic-modal-content</p> <pre><code>&lt;!-- modal content --&gt; &lt;div id="basic-modal-content"&gt; &lt;h3&gt;Are you sure you want to delete this calendar and all its associated bookings?&lt;/h3&gt; &lt;p id="modal-p"&gt; or &lt;a href='#' class='simplemodal-close'&gt;Cancel&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; </code></pre> <p>and then for my dynamic links</p> <pre><code>echo "&lt;a href='#' onclick='confirmCalendar($row-&gt;id);'&gt;Delete&lt;/a&gt;"; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload