Unable to Properly Add Javascript to Header
Permalink
I am at my wit's end here. I am working on a package for 5.7.x, and I can't get a javascript to load properly in the header.
Currently, the script I am trying to add always appears before the main jquery library. For it to work, I need to load AFTER jquery is loaded.
Here is what I have in my block controller:
I tried doing the above, but with "on_start", but got the same results.
How do I properly load package javascript in the header, but so that it shows up AFTER jquery is loaded?
Currently, the script I am trying to add always appears before the main jquery library. For it to work, I need to load AFTER jquery is loaded.
Here is what I have in my block controller:
public function view() { $html = Loader::helper('html'); $b = $this->getBlockObject(); $btID = $b->getBlockTypeID(); $bt = BlockType::getByID($btID); $uh = Loader::helper('concrete/urls'); $this->addHeaderItem($html->javascript($uh->getBlockTypeAssetsURL($bt) . '/ss-js/jquery.lifestream.js')); }
I tried doing the above, but with "on_start", but got the same results.
How do I properly load package javascript in the header, but so that it shows up AFTER jquery is loaded?
Nevermind, got it working by using the assets method.
Can you elaborate / post some code? I've done it from a package controller, but only for assets C5 provides. I'd be interested to know how to load custom block-specific JS from a block controller.
-Steve
-Steve