I was developing an odoo theme but for some reason my js is not triggering when a user is not logged in
odoo.define('n_theme.jq_website', function (require) {
'use strict';
alert('on_website');
$(".nav.navbar-nav").after('<ul class="nav_right ml-auto text-right"> </ul>');
$(".nav-item.dropdown").detach().appendTo($('.nav_right'));
$(".nav-item.dropdown").after('<ul class="trial"> 14 days</ul>');
$(".nav.navbar-nav").removeClass('ml-auto text-right');
$(".nav.navbar-nav").addClass('offcanvas-collapse');
$(".navbar-toggler.collapsed").data('toggle','offcanvas');
})
I figured out why my JS was not working and I was using the wrong inherit_id xml
#Wrong inherit_id="website.assets_editor"
<template id="myscript" name="My script" inherit_id="website.assets_editor">
<xpath expr="script[last()]" position="after">
<script type="text/javascript" src="/n_theme/static/js/script.js"/>
</xpath>
</template>
the correct one is inherit_id="website.assets_frontend"
I am not sure if I should delete the question it is so stupid