Small Javascript file is included in the header. If that file is updated to point at the correct form fields (the version on GitHub has generic #country & #state IDs) it will populate the state drop down when either United States or Canada is selected int he country drop down.
With Conservative Caching enabled the Javascript is loaded the first time the page is accessed and it disappears on subsequent visits. At least until the cache expires or is cleared, then it appears a single time again.
Linux
Database Version 5.5.50
PHP Version 5.6.23
Web Server Apache
WebServer to PHP Interface apache2handler
Joomla! Version Joomla! 3.6.0 Stable
Plugin worked correctly until 3.5 was installed.
The plugin can be found on GitHub. The Amphenol Sensors branch was written for me, developer hasn't worked with Joomla for a while so didn't know of a solution.
Currently I have Conservative Caching disabled. And we're using the Plugin - System - Page Cache based on a workaround discussed on Stack Overflow.
I've also tried some variations on when/how the Javascript file is included without success. Things like using JHTML::script
instead of ->addScript
. And other execution times besides onBeforeRender
.
To rule out something else on the production site I sucessfully reproduced the issue on a clean install of Joomla 3.6.
Yes, I updated my question.
Then add jquery before that line.
IMHO this is not joomla bug.
You should go to forum.joomla.org if you can not resolve it yourself.
If you use something that requires jquery then you have to load jquery before (ex. line before).
This will change "chain".
Fair enough. I understand the concept. Migrating the script to onContentPrepareForm
from onBeforeRender
and including the JHtml::_('jquery.framework')
solves the caching issue. (Though it does still places the included file above a bunch of other JavaScript so it might not work for all situations). And it may not be a bug in the proper sense, but considering many plugins use onBeforeRender
, (and I've seen it in tutorials) I'm still surprised at the outcome. Is there an actual reason (apparently undocumented) that caching does not work in this scenario.
TL:DR I'd still consider this a workaround as opposed to a fix at this juncture.
Oh, and to reiterate from my original post, the way the plugin was written functioned correctly before the release of Joomla 3.5.
Try something direct instead JHtml::_('jquery.framework')
$doc->addScript...
Are you saying, instead of referencing the jQuery framework via JHtml, use an explicit addScript to add jQuery?
yes, there may be bug with caching but I can not confirm now.
Category | ⇒ | Cache |
Labels |
Added:
?
|
Status | New | ⇒ | Needs Review |
Looking into this #jab17
further info that may be related: see also #16375 (comment) reggarding modules and conservative caching
Hi all,
This is happening because when Caching is set to "Conservative", the component output is fetched from the cache, meaning any code from view.html.php is not executed. This includes the:
JPluginHelper::importPlugin('content');
instructions. This plugin is a content plugin, and except on 1st page load, it's simply not loaded. Therefore it onBeforeRender handler is not registered and not executed.
I would think a content plugin should be allowed to insert js/css into the page head section and so content plugins should also be loaded when conservative caching is enabled. Not been able to pinpoint when this was changed around 3.5 release.
Maybe we have the app ensure content plugins are imported before onAfterDispatch
is dispatched?
Actually it's enough to move the plugin loading to the content controller vs in each individual per view view.html.php, as it is today. I have confirmed that.
Added information to documentation, closing this issue.
Status | Needs Review | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-06-06 18:58:59 |
Closed_By | ⇒ | nibra |
Closed_By | nibra | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/11203
Seems to be the same issue, yes.Although the PR for that other issue touches different apects.
Did you move:
$this->doc->addScript(JURI::base(true) . '/media/plg_customcontactform/js/form-actions.min.js');
to method onContentPrepareForm