Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andy Felton 185 posts 484 karma points c-trib
    Nov 17, 2016 @ 17:52
    Andy Felton
    0

    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

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Nov 20, 2016 @ 11:37
    Alex Skrypnyk
    0

    Hi Andy,

    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.

    Thanks,

    Alex

  • Alex Skrypnyk 6182 posts 24283 karma points MVP 8x admin c-trib
    Nov 30, 2016 @ 23:04
    Alex Skrypnyk
    0

    Hi Andy,

    Did you solve your task?

    Can you share ?

  • 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.

Please Sign in or register to post replies