<![CDATA[ pagination without refreshing the page - My Forums]]> https://forums.modx.com/thread/?thread=26847 <![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-533549 https://youtu.be/pVVol-gCiv4?t=2m]]> bezumkin2 Oct 22, 2015, 10:59 PM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-533549 <![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-533491
I don't use getPage for pagination, I use getResources with a limit of 0 in combination with the plugin MixItUp. Also with this combination some powerful filtering and sorting is possible.

Remark: MixItUp is not free for commercial use.]]>
sitsol Oct 21, 2015, 09:04 PM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-533491
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-505833
	$("ul.pagination a").click(function(event) {
	  event.preventDefault();
	  var clicked = $(this).attr("href");
	  $.get( clicked, function( data ) {
	    $( "#container" ).html(data);
	  });
	});
]]>
pyrographics Aug 07, 2014, 03:41 PM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-505833
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-494414 try to change this part of the snippet to:

$url=$modx->makeUrl($ajaxpage);
$furls = $modx->getOption('friendly_urls');
$qstring = !empty($furls) ? '?page=' : '&page=';
$js="
<script>
$(document).ready(function() {
new Paginator('{$url}',{qString : '{$qstring}'});
}); 
</script>
";
$modx->regClientStartupHTMLBlock($js);
]]>
Bruno17 Apr 06, 2014, 11:39 PM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=5#dis-post-494414
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-494412 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&current=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! smiley]]>
muzzstick Apr 06, 2014, 11:17 PM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-494412
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476648 Quote from: Bruno17 at Jul 19, 2013, 07:23 AM
here is a package, which should work.
didn't try to install this package, yet.

Test-example here: http://www.revo222.webcmsolutions.de/75/ajaxgetpage.html

couldn't remove the first upload, use the second one


Thank you Bruno. Will try it out.]]>
tonitox2 Sep 04, 2013, 02:35 AM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476648
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476530
Thanks,
Modxnooby
]]>
modxnooby Sep 03, 2013, 01:42 AM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476530
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476529
Thanks,
Modxnooby
]]>
modxnooby Sep 03, 2013, 01:42 AM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-476529
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-472261 didn't try to install this package, yet.

Test-example here: http://www.revo222.webcmsolutions.de/75/ajaxgetpage.html

couldn't remove the first upload, use the second one

]]>
Bruno17 Jul 19, 2013, 07:23 AM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-472261
<![CDATA[Re: pagination without refreshing the page]]> https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-472248 Bruno17 Jul 19, 2013, 05:15 AM https://forums.modx.com/thread/26847/pagination-without-refreshing-the-page?page=4#dis-post-472248