Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I remove events from the calendar and database through an AJAX call. Here is some sample code</p> <p>On event click</p> <pre><code>eventClick: function(event){ var start = $.fullCalendar.formatDate(event.start, "yyyy-MM-dd HH:mm"); var end = $.fullCalendar.formatDate(event.end, "yyyy-MM-dd HH:mm"); var id = event.id; var title = event.title; $("#edit_start").val(start); //this just populates the value into my dialog form $("#edit_end").val(end); $("#edit_title").val(title); $("#edit_event_id").val(id); $("#edit_class" ).dialog( "open" ); //open the dialog </code></pre> <p>this is the dialog info</p> <pre><code> $( "#edit_class" ).dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { "Delete Class": function() { var event_id = $("#edit_event_id").val(); $.ajax({ type:"POST", url: "delete_class.php", data: "event_id=" + event_id, }); $('#calendar').fullCalendar('refetchEvents'); //the event has been removed from the database at this point so I just refetch the events $( this ).dialog( "close" ); }, }, }); </code></pre> <p>Edit class div that shows when I open the dialog</p> <pre><code>&lt;div id="edit_class" title="Edit Class"&gt; &lt;form action=""&gt; &lt;fieldset&gt; &lt;/select&gt; &lt;p&gt; &lt;/p&gt; &lt;label for="edit_start"&gt;Start&lt;/label&gt; &lt;input type="text" name="edit_start" id="edit_start" class="text ui-widget-content ui-corner-all" /&gt; &lt;p&gt; &lt;/p&gt; &lt;label for="edit_end"&gt;End&lt;/label&gt; &lt;input type="text" name="edit_end" id="edit_end" class="text ui-widget-content ui-corner-all" /&gt; &lt;p&gt; &lt;/p&gt; &lt;label for="title"&gt;Class Name&lt;/label&gt; &lt;input type="text" name="edit_title" id="edit_title" class="text ui-widget-content ui-corner-all" /&gt; &lt;p&gt; &lt;/p&gt; &lt;label for="edit_event_id"&gt;&lt;/label&gt; &lt;input type="hidden" name="edit_event_id" id="edit_event_id" class="text ui-widget-content ui-corner-all" /&gt; &lt;/fieldset&gt; </code></pre> <p>And then on the delete_class.php page I have something like the following</p> <pre><code> $event_id = $_POST['event_id']; try { $dbh = new PDO("mysql:host=$mysql_hostname;dbname=$mysql_dbname", $mysql_username, $mysql_password); $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $dbh-&gt;prepare( "DELETE FROM events WHERE event_id = :event_id "); $stmt-&gt;bindParam(':event_id', $event_id, PDO::PARAM_STR); $stmt-&gt;execute(); } catch(Exception $e) { echo ("error"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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