template.js not executed
-
@baris said in template.js not executed:
Keep in mind the mynewtemplate.js will be loaded if the template name is also mynewtemplate.tpl
That is how I figured it would work. It seems not to be working (like this), though.
Once that page is rendered it will try to load the requirejs module forum/mynewtemplate
Do you mean, once
mynewtemplate.tpl
is rendered a file calledmynewtemplate.js
will be loaded by requirejs? I expected this to be working, something seems amiss though. Where should I start looking?Thank you,
-
That's weird. The js file gets loaded and is present in the sources tab in dev console. It's just not executed in the rendered template. Executing the js code in the console manually yields the expected result in the rendered template, though.
Any ideas how to get the js code executed?
Thanks.
-
What are the contents of that file? Have you tried just
mynewtemplate.js
instead of../client/mynewtemplate.js
? -
@pitaj said in template.js not executed:
What are the contents of that file?
"use strict"; define("mynewtemplate",function(){ var t={}; t.init=function(){$("#last-p").text("mynewtemplate.js got loaded!");}; return t }); //# sourceMappingURL=home.js.map
Have you tried just mynewtemplate.js instead of ../client/mynewtemplate.js?
You mean in the json file? I believe I tried that, too, once. Cannot remember the results. Will try again and report back.
-
@pitaj What would happen if you're using the custom pages plugin to create a route
mynewtemplate
and put widgets inside at the same time as creating a filetemplates/mynewtemplate.tpl
and a correspondingmynewtemplate.js
file?The custom pages template takes precedence it seems like. But even without the custom pages template, the
mynewtemplate.js
is not executed. -
@baris Thank you.
Well, that is where I got the JS from in the first place. I renamed the files from
quickstart.*
and added those to the custom theme, then adaptedplugin.json
. That is where I am at right now. I seem to cannot get the JS rendering to work. Template is shown, thelast-p
inner HTML is not. I'm out of clues now. -