Skip to content

Commit

Permalink
Pagination disable load more
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheu committed Jul 13, 2015
1 parent 3a3d2c4 commit 661f631
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion inc/class-mexp-resource-space-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function request( array $request ) {
'original' => true,
'results_per_page' => PJ_RESOURCE_SPACE_RESULTS_PER_PAGE,
'page' => absint( $request['page'] ),
'restypes' => 1, // Restrict to images only.
'restypes' => 1, // Restrict to images only.
) ),
sprintf( '%s/plugins/api_search/', PJ_RESOURCE_SPACE_DOMAIN )
);
Expand Down Expand Up @@ -123,6 +123,11 @@ public function request( array $request ) {

}

$response->add_meta( 'per_page', $response_data->pagination->per_page );
$response->add_meta( 'page', $response_data->pagination->page );
$response->add_meta( 'total_pages', $response_data->pagination->total_pages );
$response->add_meta( 'total_resources', $response_data->pagination->total_resources );

return $response;
}

Expand Down
15 changes: 15 additions & 0 deletions js/mexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,20 @@

});

var view = media.view.MEXP

media.view.MEXP = view.extend( {

fetchedSuccess: function( response ) {

media.view.MEXP.__super__.fetchedSuccess.apply( this, [response] );

if ( response.meta.page >= response.meta.total_pages ) {
jQuery( '#' + this.service.id + '-loadmore' ).attr( 'disabled', true );
}

}

} );

})( window, this.jQuery );

0 comments on commit 661f631

Please sign in to comment.