This issue might be a Drupal core issue not loading core/internal.jquery.form.
See this comment: https://www.drupal.org/project/drupal/issues/2755791#comment-15705409 🐛 Ajax error ajax.$form.ajaxSubmit() is not a function Needs work
On product page (Drupal 9) with variations, if I choose some variation of product (e.g size "M" instead default "S" (e.g)), I see js-errormessage: "ajax_form=1&_wrapper_format=drupal_ajax: s.$form.ajaxSubmit is not a function". After researching I found, that there are missing some js, wich are not automatically loaded:
- core/drupal.dialog.ajax
- core/jquery.form.
So. this scripts I can attach globally, and they will be loaded on all pages, what isn't neccessary, and I think if Drupal doen't load it automaticaly default on all pages, so there is a reason.
So I try to attach this scripts only to product pages, for this:
in product template "commerce-product.html.twig" I attach my custom library, e.g: "{{ attach_library('THEME/products-js') }}" , wich
I create in THEME.libraries.yml:
products-js:
version: 1.0
# js:
# js/products.js: {}
dependencies:
- core/drupal.dialog.ajax
- core/jquery.form
and here is a problem:
this scripts
- core/drupal.dialog.ajax
- core/jquery.form
will be attached to all pages, as if I attach it globally:
in source of front-page I see:
_script src="/core/assets/vendor/jquery.ui/ui/widgets/dialog-min.js?v=1.12.1"__/script_ _script src="/core/misc/dialog/dialog.js?v=9.0.8"_ _/script_ _script src="/core/misc/dialog/dialog.position.js?v=9.0.8"_ _/script_ _script src="/core/misc/dialog/dialog.jquery-ui.js?v=9.0.8"_ _/script_ _script src="/core/misc/dialog/dialog.ajax.js?v=9.0.8"_ _/script_
and the same on product-page
Nothing changed, if I comment out this lines
# js:
# js/products.js: {}
So, can you tell me please, what do I wrong or is there some bug? Thanks
Active
2.21
Product
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This issue might be a Drupal core issue not loading core/internal.jquery.form.
See this comment: https://www.drupal.org/project/drupal/issues/2755791#comment-15705409 🐛 Ajax error ajax.$form.ajaxSubmit() is not a function Needs work