Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Error: 'KTUtil' is undefined?


Hi,
I have this Error: 'KTUtil' is undefined?
Can you advise?
Thanks


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


Hi,

Please make sure that you called your js code after the core js scripts at the bottom of the page.
Please make sure that plugins.bundle.js and scripts.bundle.js are included in the page which contains KTUtil class:


<!--begin::Global Javascript Bundle(mandatory for all pages)-->
<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>
<!--end::Global Javascript Bundle-->
<script>
// On document ready
KTUtil.onDOMContentLoaded(function () {
// run your code
});
</script>


Regards.



In <b>master.blade.php</b>:

<head>
<!-- head content -->
</head>
<body>
@yield("content")
<script src="{{ asset("assets/js/app.js") }}"></script>
<script src="{{ asset("assets/plugins/global/plugins.bundle.js") }}"></script>
<script src="{{ asset("assets/js/scripts.bundle.js") }}"></script>
@yield("scripts")
</body>




In <b>_default.blade.php</b>:

@extends("layout.master")
@section("content")
@endsection

@section("scripts")
@parent <!-- Include the global scripts from master.blade.php -->
@endsection


In <b>articles.blade.php:</b>

<x-default-layout>
//some content

@section("scripts")
var KTArticlesList;
KTUtil.onDOMContentLoaded(function() {
KTArticlesList.init();
});
@endsection
</x-default-layout>


same getting KTUtil not defined error. Please advice. i even tried copying the section('scripts') code in activities.blade.php to master.blade.php AFTER the global scripts, but it's still undefined.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(