Last active
August 29, 2015 13:57
-
-
Save vgrish/9547112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>первый вызов</h2> | |
[[!AjaxSnippet? | |
&snippet=`pdoPage` | |
&element=`msProducts` | |
&tpl=`tpl.msProducts.row` | |
&limit=`3` | |
&depth=`1` | |
&parents=`4` | |
&showLog=`0` | |
&page=`[[!geturi]]` | |
&as_mode=`onload` | |
&wrapper=`tpl.ajax` | |
&tplPageActive=`@INLINE <li class="active"><a href="[[+href]]" data-pagin="page">[[+pageNo]]</a></li>` | |
&tplPageFirst=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page">[[%pdopage_first]]</a></li>` | |
&tplPageLast=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page">[[%pdopage_last]]</a></li>` | |
&tplPagePrev=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page">«</a></li>` | |
&tplPageNext=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page">»</a></li>` | |
&tplPage=`@INLINE <li><a href="[[+href]]" data-pagin="page">[[+pageNo]]</a></li>` | |
]] | |
<h2>второй вызов</h2> | |
[[!AjaxSnippet? | |
&snippet=`pdoPage` | |
&element=`msProducts` | |
&tpl=`tpl.msProducts.row` | |
&limit=`3` | |
&depth=`1` | |
&parents=`4` | |
&showLog=`0` | |
&sortdir=`DESC` | |
&page=`[[!geturi2]]` | |
&pageVarKey=`page2` | |
&as_mode=`onload` | |
&wrapper=`tpl.ajax` | |
&tplPageActive=`@INLINE <li class="active"><a href="[[+href]]" data-pagin="page2">[[+pageNo]]</a></li>` | |
&tplPageFirst=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page2">[[%pdopage_first]]</a></li>` | |
&tplPageLast=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page2">[[%pdopage_last]]</a></li>` | |
&tplPagePrev=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page2">«</a></li>` | |
&tplPageNext=`@INLINE <li class="control"><a href="[[+href]]" data-pagin="page2">»</a></li>` | |
&tplPage=`@INLINE <li><a href="[[+href]]" data-pagin="page2">[[+pageNo]]</a></li>` | |
]] | |
<script> | |
$(document).on('as_complete', document, function(e,d) { | |
$(".pagin."+d["key"]).append(d["pagination"]); | |
$(document).on('click', '.'+d["key"]+' .pagination a', function(e) { | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
var pagenum = url.substring(url.indexOf("=")+1, url.leght ) ; | |
var pagination = $(this).attr('data-pagin'); | |
if (!parseInt(pagenum)) { | |
pagenum=1; | |
Hash.remove(pagination); | |
url = url+"?"+pagination+"="+pagenum; //для стр.1 | |
} | |
else { | |
Hash.add(pagination, pagenum); | |
} | |
$.post(url, {as_action: d["key"]}, function(response) { | |
if (typeof response.output !== "undefined") { | |
$('.ajax-snippet#'+d["key"]).html(response.output); | |
$(".pagin."+d["key"]).html(response.pagination); | |
} | |
}, "json"); | |
}); | |
}); | |
</script> | |
=============== | |
tpl.ajax | |
======== | |
<div class="pagin [[+key]]"></div> | |
<div id="[[+key]]" class="ajax-snippet"> | |
<img src=" " class="as_spinner" style="width:32px;margin:auto;display:block;"> | |
</div> | |
<div class="pagin [[+key]]"></div> | |
=============== | |
geturi | |
====== | |
<?php | |
$filter = $_GET['page']; | |
return $filter; | |
=============== | |
geturi2 | |
====== | |
<?php | |
$filter = $_GET['page2']; | |
return $filter; | |
====== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment