Okay fw7 experts, need some help.
My understanding is that a content page loaded into an existing view, will NOT load the js or style tags from the page. The process is to insert those in the app.js file…so far so good.
I added the following which very nicely gets added to the content page and works properly.
$(document).on('page:init', function (e, page) {
switch (page.name) {
case "review":
var s = document.getElementsByTagName('script')[0];
var sc = document.createElement('script');
sc.type = 'text/javascript';
sc.async = false;
sc.src = 'https://maps.googleapis.com/maps/api/js?key=REDACTED-KEY&callback=initAutoComplete&libraries=places';
s.parentNode.insertBefore(sc, s);
}
HOWEVER, if I navigate to another page, and use the back function, the script is inserted again. I thought by doing this on page:init it would only execute once???
I’ve read that it might be multiple views, but I am not seeing anything other than view-main.
Ideas on how to get this script into a content page only once?