Javascript behaviours problem
JeebsUK - June 16, 2009 - 10:48
Dear all,
I was wondering if anyone has an answer to the following question I have posted on devshed:
http://forums.devshed.com/javascript-development-115/document-ready-func...
Any help would be greatly appreciated.
Cheers.

Drupal.behaviors.myModuleBehavior
Drupal is the answer to your prayers! Instead of using $(document).ready, define a new drupal behavior. See http://api.drupal.org/api/file/developer/topics/javascript_startup_guide....
Thanks but...
I do not need a new behaviour, just to re-run the initial behaviour of the tabledrag when my table has been created in my ajax call.
MySweetShadow - Heavy Metal Blog, Drupal & SEO
FiveRDesign - Drupal Development & Custom Modules
Further to the previous
Further to the previous discussion, I think that if I call drupal.attachBehaviors(); in the load event of my jquery ui tabs, it would re-initialise all the drupal behaviors, including tabledrag and draggable, but this does not seem to work. Does anyone have any further ideas or explanations as to why this doesnt work?
MySweetShadow - Heavy Metal Blog, Drupal & SEO
FiveRDesign - Drupal Development & Custom Modules
Which jQuery version are you
Which jQuery version are you using? With version 1.2.6, events can only be bound to existing elements. If the table you want to be draggable is loaded with ajax, that might cause problems. Maybe it would help to install jQuery 1.3.2 using jQuery Update (http://drupal.org/project/jquery_update) and use the new 'live evenst' feature of that release (see http://docs.jquery.com/Release:jQuery_1.3#Live_Events).
PS. I assume you already know this page: http://api.drupal.org/api/function/drupal_add_tabledrag/6.
1.2.6
Hi there,
We are using 1.2.6. I'm not really in a position to upgrade at the moment because I'm not sure what that would break, we use quite a lot of jquery on our site. The live events do sound very interesting though.
As you correctly stated, the table I want to be draggable is loaded into the ajax tab, so the initialisation of all draggable objects has already taken place well before the table is loaded. This is why I thought called drupal.attachBehaviors (either with no parameters or specifying the table id) might help, but I have had no luck with this method.
MySweetShadow - Heavy Metal Blog, Drupal & SEO
FiveRDesign - Drupal Development & Custom Modules
maybe...
I'm not 100% sure, but I'm afraid that you will not be able to do this with jQuery 1.2.6. There is one possible workaround I can think of (not sure if it works). Maybe you can put an empty table on the tab (just the table tags with the correct ID), attach the tabledrag to it and insert the table contents (tr's and td's) in the table.
Please let me know when you're able to solve this.