Form Repeater giving error "$(...).repeater is not a function"

Dear support,
We are using Metronic Laravel Demo 8.0.37. We include repeater.js in global pages config
"plugins/custom/formrepeater/formrepeater.bundle.js", when we try to use in JS its giving "$(...).repeater is not a function" error. We also try to include it in plugin.js but the result is same. We also add
window.$ = require('jquery');
require('jquery.repeater');

in "resources/assets/core/plugins/custom/formrepeater/formrepeater.js"

But still result was same.

Please help us to resolve this issue.

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 (3)

Hi Margalla,

I had this same issue. Unfortunately, the only way I could get it to work was adding it directly in the base.blade.php before the closing </body> tag.

Line -

<script src="{{ asset('demo1/plugins/custom/formrepeater/formrepeater.bundle.js') }}"></script>

I believe the reason it is saying it is not a function is it has to be loaded after JQuery ,but I may be wrong.

Hi Eric,
Thank you for your reply. I tried this solution also but still the result is same. I am getting same error.

Hi Margalla,

By default, Webpack adds a code wrapper for modular and this will cause the issue. For the below file, could you please try to change it as below? This will change the way of the build and the bundle file content.

resources/assets/core/plugins/custom/formrepeater/formrepeater.js

[
"node_modules/jquery.repeater/jquery.repeater.js"
]

Rename the file formrepeater.js to formrepeater.js.json

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