AJAX works fine for paging and exposed filters, however it does not seem to be working for table sorting. I tried on a clean install and set "Use AJAX" to "Yes" for the view on /admin/content/node2

Comments

infojunkie’s picture

What do you mean by not working? Not displaying the view? Not sorting? Not executing the operation? Please send a more detailed report including steps to reproduce, observed behaviour and expected behaviour. Thanks!

drinja’s picture

Sorry for lack of info. The table still sorts, but it does a page load instead of using AJAX.

Steps to reproduce:
Install module
Edit the View admin_content and set "Use AJAX" to "Yes"
Save View.
Visit /admin/content/node2
Click on a column header.

Expected Behavior:
Table sorts using AJAX

Observed Behavior:
Table sorts using a page load.

Additional Notes:
Paging and exposed filters both still work using AJAX.

infojunkie’s picture

Assigned: Unassigned » infojunkie

Thanks, I was able to reproduce that behaviour. I'll be working on it during the next few days. What happens when you submit the form?

infojunkie’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

I committed a fix that should be available in a few hours. Please download the latest 6.x-1.x-dev when the date on it changes to Nov 14th. Let me know how it works for you.

drinja’s picture

Thanks for the quick reply! I will test the fix and get back to you.

drinja’s picture

AJAX table sorting works for me in the latest dev. Unfortunately, the form fails to submit. This is the case when using AJAX for paging and exposed filters as well. The 6.x-1.2 release suffers the same problem for paging and exposed filters (I did not test these earlier).

Steps to reproduce:
Install module
Edit the View admin_content and set "Use AJAX" to "Yes"
Save View.
Visit /admin/content/node2
Perform a Views AJAX action (table sort, paging, or exposed filters)
Select some nodes and choose an action from the VBO dropdown.
Click execute.

Expected Behavior:
VBO action is performed.

Observed Behavior:
White screen + text printed to screen.

Text printed to screen:
{ "status": true, "display": "\x3cdiv class=\"view view-admin-content view-id-admin_content view-display-id-page view-dom-id-1\"\x3e\n \x3cdiv class=\"views-admin-links views-hide\"\x3e\n \x3cul class=\"links\"\x3e\x3cli class=\"0 first\"\x3e\x3ca href=\"/admin/build/views/edit/admin_content?destination=admin%2Fcontent%2Fnode2%3Fpage%3D1%26view_name%3Dadmin_content%26view_display_id%3Dpage%26view_args%3D%26view_path%3Dadmin%2Fcontent%2Fnode2%26view_dom_id%3D1%26pager_element%3D0#views-tab-page\"\x3eEdit\x3c/a\x3e\x3c/li\x3e\n\x3cli class=\"1\"\x3e\x3ca href=\"/admin/build/views/export/admin_content\"\x3eExport\x3c/a\x3e\x3c/li\x3e\n\x3cli class=\"2 last\"\x3e\x3ca href=\"/admin/build/views/clone/admin_content\"\x3eClone\x3c/a\x3e\x3c/li\x3e\n\x3c/ul\x3e \x3c/div\x3e\n \n \n \n \x3cdiv class=\"view-content\"\x3e\n \x3cform action=\"/views/ajax?page=1\x26amp;view_name=admin_content\x26amp;view_display_id=page\x26amp;view_args=\x26amp;view_path=admin%2Fcontent%2Fnode2\x26amp;view_dom_id=1\x26amp;pager_element=0\" accept-charset=\"UTF-8\" method=\"post\" id=\"views-bulk-operations-form-1\" class=\"confirmation\"\x3e\n\x3cdiv\x3eYou selected the following 1 rows:\x3cbr /\x3e\x3cul\x3e\x3cli\x3eHuic Inhibeo Dignissim Premo Commoveo\x3c/li\x3e\x3c/ul\x3e\x3cinput type=\"hidden\" name=\"confirm\" id=\"edit-confirm\" value=\"1\" /\x3e\n\x3cdiv class=\"container-inline\"\x3e\x3cinput type=\"submit\" name=\"op\" id=\"edit-submit\" value=\"Confirm\" class=\"form-submit\" /\x3e\n\x3ca href=\"/admin/content/node2?page=1\x26amp;view_name=admin_content\x26amp;view_display_id=page\x26amp;view_args=\x26amp;view_path=admin/content/node2\x26amp;view_dom_id=1\x26amp;pager_element=0\" class=\"active\"\x3eCancel\x3c/a\x3e\x3c/div\x3e\x3cinput type=\"hidden\" name=\"form_build_id\" id=\"form-db0ccd836826329b6960ae9f11232f0f\" value=\"form-db0ccd836826329b6960ae9f11232f0f\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_token\" id=\"edit-views-bulk-operations-form-1-form-token\" value=\"18c5f3d9a5d4f662ce9ee8aaa61689dc\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_id\" id=\"edit-views-bulk-operations-form-1\" value=\"views_bulk_operations_form_1\" /\x3e\n\n\x3c/div\x3e\x3c/form\x3e\n \x3c/div\x3e\n \n \n \n \n \n \n\x3c/div\x3e ", "title": "Content", "__callbacks": [ "Drupal.Views.Ajax.ajaxViewResponse" ], "messages": "" }

infojunkie’s picture

Yes I found it as well and that's what I was waiting for you to confirm. It's not a VBO dump so I'll try to track this down. Thanks for your patience :-)

drinja’s picture

Thanks for investigating! I'm happy to test any updates.

drinja’s picture

The bug seems to be a problem with the multi-step form. Checking "Skip confirmation step" in the dev release gets it to work as expected.

infojunkie’s picture

Good point. I have started debugging this issue and it seems that Views changes the action on *all* forms of the view (not just the pager and exposed filters) to point to view/ajax. I'll be looking for a way to defuse that behaviour cleanly. If you can provide some help there you're more than welcome :-)

An additional problem introduced by Ajax sorting is that the extra table row used by VBO to allow selection of all nodes across all pages is deleted upon sorting. That's another thing that needs to be handled.

infojunkie’s picture

Status: Active » Fixed

Fixed in the latest 6.x-1.x-dev. Please wait 12 hours before Drupal refreshes the release.

FWIW, here's a description of the problem and its solution:

Views Ajax refreshes the whole view by rebuilding it on the server and replacing the DOM of the page with the newly built fragment. For some reason, it overrode the action of the VBO form to point to views/ajax instead, although it only needs to do this on its own forms. Also, because VBO attaches JavaScript events via jQuery, these bindings are lost when the old fragment is replaced.

After going through the code of views/includes/ajax.inc & co., I found that hook_ajax_data_alter() gets called before sending the newly-built view to the Ajax caller. The object being sent back includes an array of callbacks that the JavaScript will call to perform the response handling. So I wrote my own JS callback Drupal.vbo.ajaxViewResponse() and added it to the array in views_bulk_operations_ajax_data_alter(). On the client, the callback replaces the incorrect form action with the correct URL (saved during the initial rendering of the form), and re-installs the event bindings where they should be.

Status: Fixed » Closed (fixed)

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

doc2@drupalfr.org’s picture

Woggers’s picture

This is issue is not fixed. I've got 6.x-2.3 installed and the table sorting AJAX still does not work. It refreshes the page completely.

infojunkie’s picture

Status: Closed (fixed) » Active

Reopened to investigate. Thanks.

infojunkie’s picture

Version: 6.x-1.x-dev » 6.x-1.5

Works for me. The selection is lost, yes, but the page isn't refreshed, as far as I can tell. What version of VBO are you using?

graouxx’s picture

Don't work for me when i have a date exposed filter.

Without date filter, no problem

EDIT :
In fact, the problem appears when view display no result at the first load. So don't display the bulk form.

EDIT2 :

Adding

drupal_add_js('misc/tableselect.js');
  drupal_add_js(drupal_get_path('module', 'views_bulk_operations').'/views_bulk_operations.js');
  drupal_add_css(drupal_get_path('module', 'views_bulk_operations') . '/views_bulk_operations.css', 'module');
  drupal_add_js(array('vbo' => array('url' => url($_GET['q']))), 'setting');

in init function fix the bug, but there is always a problem width date field ....

infojunkie’s picture

I can confirm that there's a problem with the date filter. With me, seems that the initial values of the exposed date filter (which is marked as optional) cause the view *not* to find any matching nodes, which throws off VBO (and Views). Can anybody confirm this or describe another scenario?

I'll be investigating the filter more closely, time permitting.

infojunkie’s picture

Status: Active » Closed (fixed)

I've closed this issue and opened another one (#445118: Date filter loses selection values) concerning the date filter specifically. If anyone is encountering a problem *without* a date filter, please re-open this issue.