← Back to Back To Front Support
Hello, I get this errors in console, when page load:
TypeError: $.oc.foundation is undefined mediamanager-browser-min.js:4:10
TypeError: $.oc.foundation is undefined october.form.js:8:16
TypeError: $.oc.foundation is undefined fileupload.js:21:16
TypeError: moment is undefinedlang.ru.js:46:14
code in layout:
'@jquery',
'@framework',
'@framework.extras',
...
{% scripts %}
In your live demo site storm-min.js
connect first (after lang.en.js, before october.form.js)
In my website storm-min.js
connect NOT first (after lang.en.js, after october.form.js)
How to fix it?
Hi!
BackToFront component has this code:
$this->assets['js'] = [
'/modules/system/assets/js/lang/lang.'.Lang::getLocale().'.js',
'/modules/system/assets/ui/storm-min.js',
'/modules/backend/assets/js/october-min.js',
];
scripts are added automatically to the page at the component level on Run() function. Pay attention to the definition of the script encoding (this is important) and whether the file with the appropriate encoding is uploaded to you correctly.
In page layout add only (not include '@framework'):
'@jquery',
'@framework.extras',
...
{% scripts %}
Also, the plugin automatically binds assets to this array (in addition to the basic ones defined above), hierarchically bypassing all works widgets
Thanks,
I found a mistake, the problem was on my side.
I had an extra code like this, I don’t know why:
foreach($this['backtofront']->controller->getAssetPaths() as $type => $assets)
foreach($assets as $asset)
$this->{'add'.ucfirst($type)}($asset);
The problem remains:
TypeError: moment is undefined in lang.ru.js:46:14
lang.js
script must be connect after storm.js
As far as I remember, the language file should be connected before storm.js is loaded (moment.js is a library for localizing dates). Your load order in the above code changes? (why is it needed if everything is loaded from the component?). Try loading Bootstrap with moment.js support (Bootstrap-Datepicker), use this code to initialize:
<script src="{{ 'assets/vendor/jquery.js'|theme }}"></script>
<script src="{{ 'assets/vendor/bootstrap.js'|theme }}"></script>
{% framework extras %}
{% scripts %}
My demo uses a standard demo theme from CMS developers (with their Bootstrap)
Last updated
I not use Bootstrap in my theme.
modules/system/assets/js/lang/lang.ru.js
line 17 shows that moment
is required initially.
I change assets js order in your plugin function prepareVars
, and the error has disappeared, I do not observe other errors.
In original backend i see lang.js
load after storm.js
.
OK. I looked at the code with a fresh mind, it’s obvious that you are right, and that’s logical (I was confused by the presence of $.oc at the beginning of the file). Strange, but in my test example in the network debugging console of Chrome, the language file is downloaded earlier than storm.js and, oddly enough, later october.js. I don’t remember for what reason lang.EN.js in my first place, but as far as I remember, there was some reason for it (an error fell out, now I don’t remember which one). Apparently the loading sequence of assets is changing (or does the file size affect?). In the next release, in the settings, I will simply add a sorting of these initial assets. Obviously, with different environments, the behavior is different. There was no such problem before your message. Thanks for the information!
1-8 of 8