I am creating a listing page on one of our sites. This listing has a load more button which when clicked will load another 15 items using AJAX which expects some HTML to be returned.
I've got the initial page working using Route Hijacking but am trying to work out the best way (Route Hijacking or API Controller) to return the HTML to be displayed for the show more.
Any ideas to help on this or people that have already approached this would be appreciated.
The best way is to have partial view with List of items as model.
So your partial view will be like:
@model List<YourCustomItem>
@{}
And than you need only controller which will get number of page and it will bind model to this view - and you will be able to call this controller from js.
You want to get html from server - than it's better to use SurfaceControllers, because API Controller is data oriented. SurfaceController has all functionality what you need. Get params, create model and return View with data.
Controllers and load more functionality
Hi,
I am creating a listing page on one of our sites. This listing has a load more button which when clicked will load another 15 items using AJAX which expects some HTML to be returned.
I've got the initial page working using Route Hijacking but am trying to work out the best way (Route Hijacking or API Controller) to return the HTML to be displayed for the show more.
Any ideas to help on this or people that have already approached this would be appreciated.
Thanks Andy
Hi Andy,
The best way is to have partial view with List of items as model.
So your partial view will be like:
And than you need only controller which will get number of page and it will bind model to this view - and you will be able to call this controller from js.
You want to get html from server - than it's better to use SurfaceControllers, because API Controller is data oriented. SurfaceController has all functionality what you need. Get params, create model and return View with data.
Thanks,
Alex
Hi Andy,
Did you solve your task?
Can you share ?
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.