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

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


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



Dear support,

I also have the same problem (undefined repeater function error) when trying out the Advanced Form Repeater Demo with Laravel.
https://preview.keenthemes....formrepeater/advanced.html
(Did not include formrepeater.bundle.js in general/pages.php)


I managed to get the Basic Repeated Demo working by including 'plugins/custom/formrepeater/formrepeater.bundle.js', in pages.php

However, when doing the same in the Advanced Form Repeater, it breaks Select2 I have on the same blade page that was activated via data-control="select2"

Also, select2 that is called via form-repeater is also broken with this error
[Error] TypeError: $('[data-kt-repeater="select2"]').select2 is not a function. (In '$('[data-kt-repeater="select2"]').select2()', '$('[data-kt-repeater="select2"]').select2' is undefined)

I have also tried including form-repeater in plugins.js and ran npm run dev --demo6 as well

Any ideas how to fix it?

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