My question is related to https://drupal.stackexchange.com/questions/98501/why-ajax-form-doesnt-work-after-paging-by-views-infinite-scroll

I try to do workaround by setting my own submit button id.

   $form['mymodule_submit'] = array(
      '#type' => 'submit',
      '#value' => $value,
      '#ajax' => array(
        'callback' => 'mymodule_like_form_ajax',
      '#attributes' => array(
        'class' => array($class),
        'id' => 'mymodule-like-form-' . $node->nid),

But in this case ajax submit doesn't work at all... What am I doing wrong here?

1 Answer 1


JS recognizes things by ID. But Drupal's AJAX only knows Drupal-generated ID. That's why when you change ID manually, it tries to attach click listeners to DOM nodes with IDs that are not there.

If you change ID to some custom value, you must also provide custom JS to attach all .on to the objects with new ID.

  • do you have any hints where to start?
    – Codium
    Jan 8, 2014 at 14:26
  • 1
    @drupality only one - find a workaround that does not require messing with IDs. Not knowing around what you are working, I can't tell better.
    – Mołot
    Jan 8, 2014 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.