Skip to main content
added 186 characters in body
Source Link
user1015214
  • 1.8k
  • 1
  • 21
  • 52

I have set an ajax callback to a form using the form api #ajax. I also have custom jquery in a file which styles part of the page and sets click handlers. I found something funny - my custom javascript only begins working AFTER the ajax has been called on the drupal form. Before I that form api ajax is called, it doesn't work.

Why would this be?

EDIT:

I am attaching my behaviors like this:

(function($) {
  Drupal.behaviors.updateCart =  {
    'attach': function(context) {
    $(document).ready(function () {...

This file is being included inside of my modules hook form alter:

if($form_id == 'commerce_checkout_form_checkout') {
  drupal_add_js('sites/all/modules/my_subscription/js/updateCart.js');
}

I have set an ajax callback to a form using the form api #ajax. I also have custom jquery in a file which styles part of the page and sets click handlers. I found something funny - my custom javascript only begins working AFTER the ajax has been called on the drupal form. Before I that form api ajax is called, it doesn't work.

Why would this be?

I have set an ajax callback to a form using the form api #ajax. I also have custom jquery in a file which styles part of the page and sets click handlers. I found something funny - my custom javascript only begins working AFTER the ajax has been called on the drupal form. Before I that form api ajax is called, it doesn't work.

Why would this be?

EDIT:

I am attaching my behaviors like this:

(function($) {
  Drupal.behaviors.updateCart =  {
    'attach': function(context) {
    $(document).ready(function () {...

This file is being included inside of my modules hook form alter:

if($form_id == 'commerce_checkout_form_checkout') {
  drupal_add_js('sites/all/modules/my_subscription/js/updateCart.js');
}
Source Link
user1015214
  • 1.8k
  • 1
  • 21
  • 52

form api ajax stops javascript loading

I have set an ajax callback to a form using the form api #ajax. I also have custom jquery in a file which styles part of the page and sets click handlers. I found something funny - my custom javascript only begins working AFTER the ajax has been called on the drupal form. Before I that form api ajax is called, it doesn't work.

Why would this be?