yiisoft / jquery-pjax

pushState + ajax = pjax
http://pjax.herokuapp.com
MIT License
144 stars 40 forks source link

Problem with page-specific JS assetbundles #23

Closed sergeantjonas closed 8 years ago

sergeantjonas commented 9 years ago

I have been implementing PJAX using the yii2-pjax plugin quite successfully. I'm using it to only load the content on my page and keep the header and sidebar static, saving quite a few seconds on not having to reload the assets added to the header and the sidebar.

However, on some of my pages I'm using certain asset bundles to load in javascript only applied to those pages. When loading in the content with pjax these asset bundles are not being registered as I expected they would be. I'm wondering if there is any way to do what I want to do or if the only solution is to add a global javascript file that includes all functions? I would rather not do this as this might create quite a big file and a lot of unused code on certain pages.

This is how I've defined my content:

    <?php Pjax::begin() ?>
         AdminAsset::register($this);
         // Content here
    <?php Pjax::end() ?>

I've looked for the majority of the day and can't find a clean solution besides having one big application.js file or using inline javascript, both of which I would like to avoid.

SilverFire commented 9 years ago

Duplicates https://github.com/yiisoft/yii2/issues/3680 Duplicates https://github.com/yiisoft/yii2/issues/4814 Duplicates https://github.com/yiisoft/yii2/issues/8540 Duplicates https://github.com/yiisoft/yii2/issues/8916 Duplicates https://github.com/yiisoft/yii2/issues/8702

SilverFire commented 8 years ago

Should be fixed by https://github.com/yiisoft/jquery-pjax/pull/30