Problem/Motivation

I want a form to be ajax submitted. As per the docs, I added class use-ajax-submit to the submit button of the form. The ajax submit is working if the page has the admin toolbar, but for users who cannot see the admin toolbar, for them it throws error:

drupal_ajax: ajax.$form.ajaxSubmit is not a function

I had to add core/jquery.form and core/drupal.ajax libraries to the form, to make it work.

Proposed resolution

Libraries core/jquery.form and core/drupal.ajax should be added by itself if use-ajax-submit class is added to the submit button.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

subhojit777 created an issue. See original summary.

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

subhojit777’s picture

Issue summary: View changes
subhojit777’s picture

Version: 8.3.5 » 8.4.x-dev
Related issues: +#2910740: Ajaxify the Remove from cart button
nod_’s picture

Version: 8.4.x-dev » 8.5.x-dev
Component: ajax system » documentation
Issue tags: +JavaScript

we don't parse information in classes to add libraries. The docs needs to be updated to say those dependencies are needed when using this class.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

subhojit777’s picture

Category: Bug report » Task
Status: Active » Needs review
StatusFileSize
new836 bytes

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: -JavaScript +JavaScript

Know we are trying to move away from jQuery right? So is this still needed?

nod_’s picture

Status: Postponed (maintainer needs more info) » Needs work

we're trying but it's not something in the near future. To make docs accurate that would be needed.

The comment could use some work, in particular saying those 2 things are libraries to attach.

kunalgautam’s picture

Status: Needs work » Needs review
StatusFileSize
new836 bytes

Patch for Drupal 10.1

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @kkalashnikov but the patch #8 still applied cleanly to 10.1 so the reroll was not needed. Removing credit for that.
You can verify if a patch still applies to a specific branch by clicking test/retest under it.

Also with patches, even rerolls, please upload an interdiff

Thank you @nod_ for explaining that. So the documentation change in #8 looks good and simple then

Thanks

kunalgautam’s picture

StatusFileSize
new1.35 KB

Hello @smustgrave this is the interdiff of #8 and #20 patch.

catch’s picture

Status: Reviewed & tested by the community » Needs work

#19 still needs to be addressed - the comment should explicitly say these are libraries, and use attach/attached/#attached instead of 'include'.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new835 bytes
new1.35 KB

Updated patch #8 by addressing #23, please review it.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Not sure if that can be cleaned up more but adds value as is currently.

catch’s picture

Status: Reviewed & tested by the community » Needs work

It still doesn't say explicitly that these are libraries. like 'you will need to attach the libraries .... to the form' or something.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

timodwhit’s picture

The pull request/solution no longer seems valid: https://www.drupal.org/node/3293156

The user would need to create a new library for jquery.form and then attach it to the form it appears.

timodwhit’s picture

bhanu951’s picture

I think we can close it as a duplicate of #2755791: Ajax error ajax.$form.ajaxSubmit() is not a function as it has working patch.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.