https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39567

--- Comment #16 from Paul Derscheid <[email protected]> ---
You could just replace this:
<script type="module">
    import { submit_form } from "/intranet-tmpl/prog/js/form-submit.js";
    $("body").on("click", ".submit-form-link", function (e) {
        e.preventDefault();
        submit_form(this);
    });
</script>

with this:
[% Asset.js("js/form-submit.js", { 'type' => 'module' }) | $raw %]

And then call it within form-submit.js:
$("body").on("click", ".submit-form-link", function (e) {
    e.preventDefault();
    submit_form(this);
});

... rest of the code

That way we still have this module but no inline code is required in
js_includes.inc for example.

David's suggestion regarding an esm path and a caller makes sense, but I think
just for this one function, introducing that is not necessary.

If we decided not to export the function, you could also just wrap it with
(() => {
   <content of form-submit.js>
})();
and have it as an IIFE rather than a module. Which would then also shorten the
Asset.js call to:
[% Asset.js("js/form-submit.js") | $raw %]

But that really depends on whether the exported function is in use outside of
the context of form-submit.js itself. Maybe an IIFE is more fitting and can
later be replaced by an exported function if the need arises?

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to