I have ran into a few different issues that are similar to the issue I am experiencing but haven't seen anything that is exactly the same, so I apologize if this is a duplicate. And this issue really be in ctools and not views. but im starting here.

So I have a very basic view, this view just displays node teasers of a product, and each of these products has an add to cart form. This view is rendered inside of a ctools modal dialog. Fairly straight forward as demonstrated below

function corning_ajax_class_application() {
    ctools_include('modal');

    $view = views_get_view('class_application_popup');
    $view->use_ajax = TRUE;
    $output[] = ctools_modal_command_display(t('Studio Classes'), $view->render());

    print ajax_render($output);

}

function corning_form_uc_product_add_to_cart_form_alter(&$form, &$form_state) {
    // AJAXify the add to cart for
    if (arg(0) == 'ajax') {
        $form_state['ajax'] = TRUE;
    }
}

The view works perfectly when I initially bring up the modal, I can submit the cart form on the individual nodes and they use ajax as suspected. However, once the exposed filters form has been clicked or paging is used they no longer get processed, and clicking on the cart submits just loads the ajax request page. After digging into this for a while I found that I can get the forms to be processed again by manually calling Drupal.behaviors.ZZCToolsModal.attach('#modalContent'); from the console after the exposed filter form has been submitted, and it appears that Drupal.attachBehaviors() is called several times when the modal is loaded. But after paging or using the exposed filter forms Drupal.attachBehaviors() is only called once, and it doesn't look like its getting called after the content has been loaded onto the page.

That is my hunch anyway. Some input from someone with a deeper knowledge of the inner workings of this process would be greatly appreciated.

Comments

merlinofchaos’s picture

Hmm. That's strange.

View paging just uses ajax_command_replace() which uses the 'insert' command with the 'replaceWith' method. It calls both detachBehaviors and attachBehaviors naturally in core.

So I'm not sure why or how attachBehaviors might not be getting run. Maybe check in ajax.js and see what's actually happening during the paging response?

cangeceiro’s picture

Ok, I will dig thru there and see if i can find a better way to fix this, I was able to get around it with the following but i dont really see this being anymore then a hack instead of a real fix.

    $(document).ajaxComplete(function(event, XMLHttpRequest, ajaxOptions){

        response = XMLHttpRequest.responseText;
        result = response.search(/"status": false/i);

        if(result == -1 && ajaxOptions.url == '/views/ajax'){
            Drupal.behaviors.ZZCToolsModal.attach('#modalContent');
        }
    });
kars-t’s picture

Status: Active » Fixed

Hi

I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.

Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Version: 7.x-3.0-rc3 » 7.x-3.x-dev
Issue summary: View changes
Status: Closed (fixed) » Needs review

Experiencing the same problem today with current dev release of views. Not sure if there is a connection but I get the following error information when admin (using administrative menu) accesses any /user which happens to have a panels display with a series of views including a view that contains a node/add form.

Uncaught TypeError: undefined is not a function
b.extend.each
$.fn.once
Drupal.behaviors.ZZCToolsModal.attach
(anonymous function)
b.extend.each
Drupal.attachBehaviors
(anonymous function)
b.extend.ready
u

Anonymous’s picture

Getting this problem when admin user with admin menu installed runs CKEditor Module with CKEditor 4.x editor in any browser. Autenticated users without the admin menu are not affected.

Uncaught ReferenceError: mod_pagespeed_luq6FxfPZ9 is not defined user:46
(anonymous function)

Uncaught TypeError: undefined is not a function js_wZqyCQNsGyTy0vkEP1ssL3m7T1_LkdjOCuEueirxSk4.js.pagespeed.jm.d0z_WLdPie.js:65
(anonymous function) js_wZqyCQNsGyTy0vkEP1ssL3m7T1_LkdjOCuEueirxSk4.js.pagespeed.jm.d0z_WLdPie.js:65
b.extend.each js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:1
b.fn.b.each js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:1
$.fn.once js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:5
Drupal.behaviors.ZZCToolsModal.attach js_wZqyCQNsGyTy0vkEP1ssL3m7T1_LkdjOCuEueirxSk4.js.pagespeed.jm.d0z_WLdPie.js:64
(anonymous function) js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:6
b.extend.each js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:1
Drupal.attachBehaviors js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:6
(anonymous function) js_xAPl0qIk9eowy_iS9tNkCWXLUVoat94SQT48UBCFkyQ.js.pagespeed.jm.Dx0OC_FZRm.js:19
b.extend.ready

Uncaught ReferenceError: __adroll is not defined ads?client=ca-pub-5099733402433578&output=html&h=600&slotname=6646834674&adk=2913288502&w=160&lmt=1…:34
(anonymous function) ads?client=ca-pub-5099733402433578&output=html&h=600&slotname=6646834674&adk=2913288502&w=160&lmt=1…:34
(anonymous function)

mustanggb’s picture

Category: Support request » Bug report
Status: Needs review » Postponed (maintainer needs more info)

Seems like it might be a bug, but does it still occur?

mustanggb’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

No reply.