Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Error: 'KTUtil' is undefined?


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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(