Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $99
Get for 99$

Metronic 9 laravel - Use jQuery CHOSEN plugin


Hello,
I would like add jquery CHOSEN plugin to my metronic project with Laravel, i can't do it.
I have donwload the plugin and placed it in the directory /public/access/plugins.
I have include it in master.blade.php like this :

<link rel="stylesheet" href="/assets/plugins/chosen/chosen.css" type="text/css">
<script src="/assets/plugins/chosen/chosen.jquery.js"></script>

It doesn't work, i h va an error in the console :
Uncaught ReferenceError: jQuery is not defined

I'm desperate because ireally need this library in my project, coul you help me to include this library properly ?

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 Fabien,

In Metronic v9, jQuery is not included by default. You’ll need to install it yourself to use the Chosen plugin.

You can add jQuery to your project by installing it via npm or including it from a CDN. Here's how you can do it:

Option 1: Install with npm
Run the following command in your project directory:

npm install jquery


Import jQuery in your app.js or wherever you need it:

import $ from "jquery";
window.$ = window.jQuery = $;


Option 2: Use a CDN
Add the following script tag before the Chosen plugin in your master.blade.php:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="/assets/plugins/chosen/chosen.css" type="text/css">
<script src="/assets/plugins/chosen/chosen.jquery.js"></script>


After that, initialize the Chosen plugin properly:

$(document).ready(function() {
$(".chosen-select").chosen();
});



(I'm not part of Metronic team... just trying to help)

there is no jQuery bundled in Metronic 9.

you need to add it by yourself, eighter adding the JS file to your assets folder or using a CDN.

See: https://releases.jquery.com/


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  :(