Closed (fixed)
Project:
DraggableViews
Version:
6.x-3.2-beta5
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2009 at 16:18 UTC
Updated:
23 Sep 2009 at 18:07 UTC
Hi,
I am attempting to update a table using AJAX. I have created a module that provides the contents of the table using the calls:
$block = module_invoke('views', 'block', 'view', 'block-name');
print drupal_json($block['content']);
I get the contents fine, however the table is no longer draggable.
My though was that it might have something to do with the file tabledrag.js. I found this link however I'm unsure if this is the correct approach.
Would I instead need to structure the module_invoke() call differently?
Any help would be appreciated.
Bill
Comments
Comment #1
sevi commentedI suppose the problem is that the tabledrag.js as well as the tabledrag-settings array will not be loaded.
The DraggableViews preprocess theme function calls
drupal_add_tabledrag(..). This call appends all needed javascripts to the $scripts array. On a page request this $scripts array will be outputted in the head-section in the page.tpl.php (depending on your theme).But if you use an AJAX requests your head-section won't change and the tabledrag settings array will not be outputted. Thus the view won't be draggable.
You've to include the tabledrag.js and you've to call the tabledrag settings functions on your own.
I suppose this is actually not a DraggableViews issue.
Comment #2
sevi commentedReopen if needed.
Comment #3
vegeneric commentedi'm struggling with this same issue... although i realize it is perhaps not a draggableviews problem, any additional guidance would be appreciated. i'm currently using the flag module in conjunction with block_refresh to allow users to build a shortlist of content selections. when someone flags or unflags a node the selections block refreshes automatically with the new content. however, i'd like the selections to be draggable, and when the block is refreshed the draggable js is not re-run.
my understanding is that a simple calling of Drupal.attachBehaviors(); is the built-in drupal solution to re-running necessary javascript after an ajax load, so i'm not quite clear why that alone is not enough in this case.
regardless, if anyone could provide more specific information about which tabledrag.js functions i need to call & with which parameters to re-build my draggable table after the ajax load it'd make my day :)