Copied to clipboard

Flag this post as spam?

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


  • Andy 10 posts 81 karma points
    Mar 10, 2016 @ 12:58
    Andy
    0

    Recreating the Hybrid Framework AjaxVacancyoverview pagination

    Hello everyone,

    Wondered if someone could help me; the nuts of the problem is I am getting a 404 from ActionResult in a SurfaceController.

    I am trying to replicate the ajax pagination in AjaxVacancyoverview example in the Hybrid Framework.

    Hence I have add the following:

    To my controller:

    public ActionResult AjaxNewsList()
            {
                //We don't use CreateMasterModel because we dont need the base model properties.
                //Only the vacancy overview part is reloaded.
                var model = GetContainer();
    
                //This page is loaded with jquery and sometimes it loads old (cached) data. This prevents that.
                Umbraco.DisableCache();
    
                return CurrentTemplate(model);
            }
    

    An additional view called: AjaxNewsList.cshtml:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<NewslistContainer>
    @{
        Layout = "Custom.cshtml";
    }
    
    @Html.Partial("NewsListContainer", Model)
    

    An finally my js:

    function initAjaxPaging() {
        if ($('.pagination').length) {
            // Setup content
            initContent();
            // Setup loader
            $(".vacancy-layer").prepend("<div class='do-loader abslt' style='display:none;'><img src='/css/images/bx_loader.gif' border='0' /></div>");
    
            $(document).ajaxComplete(function () {
                //Update the url's again.
                initContent();
                //Show the new content with a fade effect.
                $(".do-loader").fadeOut(250);
            });
    
            $.address.change(function (event) {
                var page = event.parameters['page'];
    
                if (page) {
                    var qs = "?page=" + page
    
                    var level = event.parameters['level'];
                    if (level){
                        qs += "&level=" + level
                    }
    
                    //Build the ajax url.
                    var ajaxUrl = $.address.baseURL().split('?')[0];
                    if (!endsWith(ajaxUrl, "/")) {
                        ajaxUrl += "/";
                    }
                    ajaxUrl += "ajaxnewslist/";
    
                    // Load content
                    $(".do-loader").fadeTo(0, 0.8, function () {
                        $(".vacancy-overview").load(ajaxUrl + qs);
                    });
                }
            });
        }
    }
    

    As per the AjaxVacancyoverview; the problem is I am getting a 404 from my AjaxNewsList() ActionResult.

    In the HybridFramework If I can the of the ajaxUrl , view name and action result in the controller from AjaxVacancyoverview to AjaxVacancyoverview2 I also receive a 404 which makes me think I have missed a single step.

    Can someone please help me; been looking at this for nearly 2 days now and still am stuck.

Please Sign in or register to post replies

Write your reply to:

Draft