I've run into a little Problem with my TYPO3 Extension I created with the Extension Builder. The Extension generates a Calendar and shows a list of upcoming events. Calendar with listed events
code list.html
<div id="dncalendar-container"></div>
<f:flashMessages />
<div class="tx_tbpartnereventcal">
<f:for each="{events}" as="event">
<f:link.action class="event-cont" action="show" controller="Events" arguments="{events : event}" target="popup">
<span class="event-title">{event.title}</span> <span class="event-date"><f:format.date format="Y-m-d">{event.date}</f:format.date></span><br>
</f:link.action>
</f:for>
</div>
<!--<f:debug>{_all}</f:debug>-->
<f:format.raw>{scriptDates}</f:format.raw>
<script type="text/javascript">
//script to generate calendar
</script>
the list is created via the standard listAction in the controller and the elements can be clicked to show detailed information about each event.
However, when clicking on a linked Listitem, it reloads the pluginarea with the deatailed information as a new page. I would prefer it if the div.tx_tbpartnereventcal would just change the content of itself to the detailed information.
I have no idea however, how to get that working with ajax in TYPO3 or if there is another way.
Code controller action list and show:
/**
* action list
*
* @return void
*/
public function listAction()
{
$events = $this->eventsRepository->findAll();
$this->view->assign('events', $events);
/* get all events and turn into json for js calendar */
$allNotes ='';
/** @var Event $event */
foreach ($events as $event) {
$tempArr=array("date"=>$event->getDate()->format("Y-m-d"), "note" =>$event->getTitle(), "description" => $event->getLink(), "optional"=> "stuff");
$allNotes .= json_encode($tempArr).",";
}
/* create script to use data in js in .html */
$script = "
<script>
var jsondate = [".$allNotes."];
</script>
";
/* send js script to list.html to insert into js calendar */
$this->view->assign('scriptDates', $script);
}
/**
* action show
*
* @param \TBPartnerNet\TbPartnerTerminkalender\Domain\Model\Events $events
* @return void
*/
public function showAction(\TBPartnerNet\TbPartnerTerminkalender\Domain\Model\Events $events)
{
$this->view->assign('events', $events);
}
Am thankfull for any help!