http://doc.silverstripe.org/doku.php?id=recipes:ajax_basics
The above doc explain the basic usage of ajax in silverstripe site. The two example it presents, the first one is a static message gets displayd in the ajaxContent area, whereas the second one is image rendered in by ajaxSnippet template, and I did notice you can put some dynamic element, such as $Title inside the template.
What I would like to know is, if I need to display a collection of page's summary in the ajaxContent, how do I did it with a template?
ie: $eventPages = DataObject::get('EventPage', 'ParentID=$this->ID', '', '', '')
I need a template for the ajax content, so that I could style it.
if I do the following, I miss the opportunity of using renderWith,
if($this->isAjax) {
return $eventPages;
//return "this is a test for ajax";
} else {
return Array();
}
I certainly can not do this, because I need to return a data object set, not just a static template.
if($this->isAjax) {
return $this->renderWith("ajaxSnippet");
}
else {
return Array();
}
I have also try the following, sort of merge the two, but failed
if($this->isAjax) {
return $EventPages->renderWith("ajaxSnippet");
}
else {
return Array();
}