Dodanie paginacji z możliwością wprowadzania numeru strony w formacie input oraz poprawa stylów dla elementów paginacji
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
Strona <span id="current-page"><?= $this -> current_page;?></span> z <span id="max_page"><?= $this -> pagination_max;?></span>
|
||||
Strona <input type="number" id="current-page" value="<?= $this -> current_page;?>"> z <span id="max_page"><?= $this -> pagination_max;?></span>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
@@ -92,6 +92,23 @@
|
||||
ajax_load_products( 1 );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.pagination input[type="number"]', function() {
|
||||
var current_page = $( this ).val();
|
||||
var pagination_max = parseInt( $( '.pagination' ).attr( 'pagination_max' ) );
|
||||
|
||||
if ( current_page > pagination_max ) {
|
||||
current_page = pagination_max;
|
||||
$( this ).val( current_page );
|
||||
}
|
||||
|
||||
if ( current_page < 1 ) {
|
||||
current_page = 1;
|
||||
$( this ).val( current_page );
|
||||
}
|
||||
|
||||
ajax_load_products( current_page );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.pagination a', function() {
|
||||
var current_page = $( this ).attr( 'page' );
|
||||
ajax_load_products( current_page );
|
||||
|
||||
Reference in New Issue
Block a user