Copied to clipboard

Flag this post as spam?

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


  • Daniel Rogers 143 posts 742 karma points
    Apr 19, 2020 @ 14:09
    Daniel Rogers
    0

    JS for Partial view dont run when loaded via another script

    I have a partial view that has some images that represent the first page different catalogs. When the image is clicked if runs a js.

    function RefreshCatalog(id) {
        $.ajax({
            type: "POST",
            url: '/umbraco/surface/CustomComponentSurface/IBDLaodCatalog',
            data: { CatIndex : id },            
            success: function (responce) {
                $('.turn-flipbook').html(responce);
            }
        });
    }
    

    Id represents the content id

        [HttpPost]
        public ActionResult IBDLaodCatalog(string CatIndex)
        {
            try
            {
                IPublishedContent model = Umbraco.Content(CatIndex);
    
                return PartialView(PARTIAL_VIEW_COMPONENTS_FOLDER + "IBDFlipBook.cshtml", model);
            }
            catch 
            {
                return null;
            }
        }
    

    The Partial view loads however there is a load of javascript (turn.js) that needs run to load the catalog but this dosent run. only that aspects of the view are displayed that are not populated from the scripts.

    How do I get around this.

  • Daniel Rogers 143 posts 742 karma points
    Apr 22, 2020 @ 14:48
    Daniel Rogers
    100

    Solved

    Placed the turn.js flipbook partial in a Ajax form as well as loading the javascript inside it rather than in the and it worked perfect.

  • 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" button below.

    Continue discussion

Please Sign in or register to post replies