I too am having some trouble getting this to work.
I've got getPage working no problem with my custom snippet but I'm getting a 404 error when attempting to use Bruno's jQuery component above.
From Firebug: "NetworkError: 404 Not Found -
http://localhost/modx/index.php?id=3?id=3&items=10¤t=1"
My custom snippet (working perfectly when not using ajax):
<?php
$myComponent = $modx->getService('myComponent','MyComponent',$modx->getOption('mycomponent.core_path',null,$modx->getOption('core_path').'components/mycomponent/').'model/mycomponent/',$scriptProperties);
if (!($myComponent instanceof MyComponent)) return 'Unable to load the voting system!';
$competitionId = 9; // hardcoded this for now
// Get total number of records
$c = $modx->newQuery('items');
if(!empty($competitionId)) {
$c->where(array(
'competition_id' => $competitionId
));
}
$total = $modx->getCount('items',$c);
/* setup default properties */
$limit = $modx->getOption('limit',$scriptProperties,6);
$offset = $modx->getOption('offset',$scriptProperties,0);
$sort = $modx->getOption('sort',$scriptProperties,'id');
$dir = $modx->getOption('dir',$scriptProperties,'asc');
$totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
$modx->setPlaceholder($totalVar,$total);
$c->limit($limit,$offset);
$c->sortby($sort,$dir);
$artworks = $modx->getCollection('items',$c);
/* iterate */
$output = '';
foreach ($artworks as $artwork) {
$artworkArray = $artwork->toArray();
$output .= $myComponent->getChunk($tpl,$artworkArray);
}
return $output;
My "home" resource:
[[!ajaxGetPage? &ajaxpage=`3`]]
<!-- Begin Pagination code -->
<div id="pagination_controls">
<div id="pagination_control_wrapper">
</div>
</div>
<div id="pagination_container">
<div id="pagination_content_wrapper">
</div>
</div>
<!-- End Pagination code -->
My ajax resource with an id of 3 and a blank template:
[[!ajaxGetPage?
&ajax=`1`
&sortBy=`id`
&elementClass=`modSnippet`
&element=`mycustomsnippet`
&tpl=`myRowTpl`
&totalVar=`total`
&limit=`2`
]]
and here is the template I'm using "myRowTpl"
<li>
<table>
<tr><th>[[+name]]</th></tr>
<tr><td>[[+description]]</td></tr>
<tr><td><a href="/modx/assets/components/mycomponent/competitions/[[+competition_id]]/[[+filename]]"><img src="/modx/assets/components/mycomponent/competitions/[[+competition_id]]/thumbnails/[[+filename]]_medium.jpeg"></a></td></tr>
<tr><td><a href="">Vote!</a></td></tr>
</table>
</li>
If there's anything obvious that I'm missing, please let me know!