Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS4.1.0 BUG: x-include-js header doesn't work #2156

Closed
a2nt opened this issue Apr 28, 2018 · 6 comments
Closed

SS4.1.0 BUG: x-include-js header doesn't work #2156

a2nt opened this issue Apr 28, 2018 · 6 comments

Comments

@a2nt
Copy link
Contributor

a2nt commented Apr 28, 2018

Looks like SS 4.1 GridField doesn't load JS+CSS on AJAX for example:

Symbiote\GridFieldExtension\GridFieldExtensions has include_requirements function

class GridFieldExtensions
{
   public static function include_requirements()
   {
       Requirements::css('symbiote/silverstripe-gridfieldextensions:css/GridFieldExtensions.css');
       Requirements::javascript('symbiote/silverstripe-gridfieldextensions:javascript/GridFieldExtensions.js');
   }
}

It will be loaded on regular request to /admin/pages/edit/show/1, but it won't be loaded on AJAX request when you select a page from tree view menu.

I have checked AJAX response headers x-include-css and x-include-css and both of them contain required files, but only CSS will be loaded

x-include-css: /resources/vendor/silverstripe/admin/client/dist/styles/bundle.css?m=1520903238,/resources/vendor/dnadesign/silverstripe-elemental/client/dist/styles/bundle.css?m=1522881332,/resources/vendor/dnadesign/silverstripe-elemental-virtual/css/elemental-admin.css?m=1522881333,/resources/vendor/silverstripe/asset-admin/client/dist/styles/bundle.css?m=1519781483,/resources/vendor/silverstripe/campaign-admin/client/dist/styles/bundle.css?m=1517977337,/resources/vendor/silverstripe/cms/client/dist/styles/bundle.css?m=1520973954,/resources/vendor/symbiote/silverstripe-gridfieldextensions/css/GridFieldExtensions.css?m=1518386927,/resources/vendor/colymba/gridfield-bulk-editing-tools/client/dist/styles/main.css?m=1521060281
x-include-js: /resources/vendor/silverstripe/admin/client/dist/js/vendor.js?m=1520903238,/resources/vendor/silverstripe/admin/client/dist/js/bundle.js?m=1520903238,/resources/vendor/silverstripe/admin/thirdparty/bootstrap/js/dist/util.js?m=1520903238,/resources/vendor/silverstripe/admin/thirdparty/bootstrap/js/dist/collapse.js?m=1520903238,/resources/vendor/silverstripe/admin/client/lang/en.js?m=1520903238,/resources/vendor/silverstripe/admin/client/dist/js/LeftAndMain.Ping.js?m=1520903238,/resources/vendor/symbiote/silverstripe-gridfieldextensions/javascript/GridFieldExtensions.js?m=1518386927,/resources/vendor/jonom/silverstripe-betternavigator/javascript/BN.LeftAndMain.Preview.js?m=1523054468,/resources/vendor/silverstripe/asset-admin/client/lang/en.js?m=1519781483,/resources/vendor/silverstripe/asset-admin/client/dist/js/bundle.js?m=1519781483,/resources/vendor/silverstripe/campaign-admin/client/lang/en.js?m=1517977337,/resources/vendor/silverstripe/campaign-admin/client/dist/js/bundle.js?m=1517977337,/resources/vendor/silverstripe/cms/client/dist/js/bundle.js?m=1520973954,/resources/vendor/silverstripe/cms/client/dist/js/SilverStripeNavigator.js?m=1520973954,/resources/vendor/silverstripe/cms/client/lang/en.js?m=1520973954,/resources/vendor/colymba/gridfield-bulk-editing-tools/client/dist/js/main.js?m=1521060281,/resources/vendor/colymba/gridfield-bulk-editing-tools/client/lang/en.js?m=1521060281
@chillu
Copy link
Member

chillu commented Jul 8, 2018

@maxime-rainville Can you please validate this bug in the CMS and check that it's applicable broader than just this module? Only then it would warrant a ~5pt fix.

@a2nt
Copy link
Contributor Author

a2nt commented Jul 9, 2018

Just to make it easier to check I have fixed this bug here: jonom/silverstripe-text-target-length#17

@maxime-rainville
Copy link
Contributor

I tried including some JS in a DataObject CMS form to see if it gets loaded. That part worked fine.
I install Symbiote\GridFieldExtension in SS4x and everything is loading fine for me.

@robbieaverill
Copy link
Contributor

I'm having a similar problem, but my JS requirements are in the X-IncludeJS header. Related: silverstripe/cwp#141

@blueo
Copy link

blueo commented Aug 29, 2018

I think what might be happening is similar what is happening in this bug: silverstripe/silverstripe-framework#8346. Basically, jquery.ondemand is checking to see if the file is loaded before requesting a new one. It is possible that all the files in that header are already loaded so you won't see any load?. You could test by adding a different file and checking if it is loaded. The method in question you can find here

@bergice bergice self-assigned this Sep 20, 2018
@bergice
Copy link
Contributor

bergice commented Sep 24, 2018

I've investigated this and it seems like it does load the JS, but since we handle this differently with jquery.ondemand.js it does not get added to sources, but is instead dynamically injected and will show up as a VM script.

The CSS however is loaded normally which is why you see it under sources.

I'll close this issue.

@bergice bergice closed this as completed Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants