richardhj/contao-ajax_reload_element und cal_default.html5
Hallo,
lokale Installation 4.11.5
Die Erweiterung [richardhj/contao-ajax_reload_element] installiert.
Die cal_default.html5 angepasst
PHP-Code:
<table class="calendar">
<thead>
<tr>
<th colspan="2" class="head previous calendar__prev"><?php if ($this->prevHref): ?><a href="<?= $this->prevHref ?>" title="<?= $this->prevTitle ?>"><?= $this->prevLink ?></a><?php else: ?> <?php endif; ?></th>
<th colspan="3" class="head current"><?= $this->current ?></th>
<th colspan="2" class="head next calendar__next"><?php if ($this->nextHref): ?><a href="<?= $this->nextHref ?>" title="<?= $this->nextTitle ?>"><?= $this->nextLink ?></a><?php else: ?> <?php endif; ?></th>
</tr>
<tr>
<?php foreach ($this->days as $day): ?>
<th class="label<?= $day['class'] ?>"><?= Patchwork\Utf8::substr($day['name'], 0, $this->substr) ?><span><?= Patchwork\Utf8::substr($day['name'], $this->substr) ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ($this->weeks as $class => $week): ?>
<tr class="<?= $class ?>">
<?php foreach ($week as $day): ?>
<td class="<?= $day['class'] ?>">
<div class="header"><?= $day['label'] ?></div>
<?php foreach ($day['events'] as $event): ?>
<div class="event cal_<?= $event['parent'] ?><?= $event['class'] ?>" itemscope itemtype="http://schema.org/Event">
<a href="<?= $event['href'] ?>" title="<?= $event['title'] ?> (<?php if ($event['day']): ?><?= $event['day'] ?>, <?php endif; ?><?= $event['date'] ?><?php if ($event['time']): ?> <?= $event['time']?><?php endif; ?>)"<?= $event['target'] ?> itemprop="url"><span itemprop="name"><?= $event['link'] ?></span></a>
</div>
<?php endforeach; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script>
$(".calendar__next, .calendar__prev").click(function (event) {
var element;
//Get url of next Month
var $url = window.location.origin + '/' + $(this).attr('href');
// Don't follow the link
event.preventDefault();
// This is the elements div container like ".mod_my_module". "Allow ajax reload" has to be ticket for this element in the backend
element = $(this).closest('[class^="ce_"],[class^="mod_"]');
// Add a css class to this element. An overlay and spinning icon can be set via css
element.addClass('ajax-reload-element-overlay');
$.ajax({
method: 'POST',
url: $url,
data: {
// The data- attribute is set automatically
ajax_reload_element: element.attr('data-ajax-reload-element')
}
})
.done(function (response, status, xhr) {
if ('ok' === response.status) {
// Replace the DOM
element.replaceWith(response.html);
} else {
// Reload the page as fallback
location.reload();
}
});
});
</script>
Im Artikel "Ajax-Reload erlauben" erlaubt.
Im Contentelement 'Modul' selbst wird "Ajax-Reload erlauben" nicht angeboten.
Im Modul/Modultyp 'Kalender' wird kein "Ajax-Reload erlauben" angeboten.
Im Frontend wird der click-event auch ausgeführt, denn nach dem Klick wird die class hinzugefügt
PHP-Code:
<div class="mod_calendar events-calendar block ajax-reload-element-overlay">
... aber mehr passiert nicht.
Im Devtool bekomme ich keinen Fehler angezeigt.
Also der Kalender verbleibt am aktuellen Monat und ein vor- und zurückklicken funktioniert nicht.
Kann mir jemand weiterhelfen?
vielen Dank