I've searched for other similar questions, but no answer works for my problem.
Here is my jQuery:
$("i[id^='delete']").click(function() {
$(".container.tim-container").load("getreservations.php");
});
And here is the php that generates the updated content:
$count = 0;
echo '<div class="container tim-container">';
echo "<div>";
echo '<h1 class="title">View Reservations</h1>';
echo "</div>";
echo '<div class="reservations">';
foreach ($noDupes as $facilities)
{
echo '<div class="col-sm-12 left-column">';
echo '<h2 id="facility_name'.$count.'" class="facility-title">'.$facilities["facility_name"].'</h2>';
echo '</div>';
foreach ($facilities["dates"] as $dates => $dateValues)
{
echo '<div class="col-sm-3 left-column">';
echo '<h4 id="facility_date'.$count.'" class="facility-title">'.$dateValues["date"].'</h4>';
echo '</div>';
echo '<div class="col-sm-9 right-column">';
echo '<ul>';
foreach($dateValues["timeslots"] as $timeslots => $timeslotValues)
{
echo '<p id="start_time'.$count.'" hidden>'.$timeslotValues["start_time"].'</p>';
echo '<p id="end_time'.$count.'" hidden>'.$timeslotValues["end_time"].'</p>';
echo '<li class="row time-slot text-align">';
echo '<h4 class="display_inline">'.$timeslotValues["start_time"].':00 - '.$timeslotValues["end_time"].':00</h4><i id="delete'.$count.'" class="fa fa-trash-o"></i>';
echo '</li>';
$count++;
}
echo '</ul>';
echo '</div>';
}
}
echo '</div>';
echo '</div>';
Even though it is not beautiful php code, it works. The problem is that the .load()
function in jQuery only works once. Also, I've tried using .on('click', function(){})
on the <i>
element as well. How can I make it work more than once?