[development] Passing a client value back to Drupal

Anthony Malkoun malkouna at yahoo.com.au
Tue Mar 29 23:49:45 UTC 2011


I don't use CTools, but how I normally do this is define in the module a 
hook_menu item that is purely callback (i.e. 'type' => MENU_CALLBACK) 
and use that.  Tabular data I push using a jQuery $.ajax call and just 
serialize() the whole data HTML element.  To pass something back in the 
callback function (in module) just encode it using json_encode and in 
jQuery $.ajax call have a success handler that does something with it.

Malks.

On 6:59 AM, jeff at ayendesigns.com wrote:
> It probably seems that I am using this list as my first line of 
> defense, since it's been fairly inactive between my posts! But 
> honestly, I have spent hours and hours and hours in issue queue, IRC 
> (including ##javascript #jquery), Google, source code, handbook 
> pages...   I feel like the guy amongst the trees looking for a forest.
>
> Part of this is documented at http://drupal.org/node/1106358, for 
> background...the last 2 or 3 responses being most applicable. 
> Basically, I am doing a hook_form_alter and adding a #suffix to the 
> node edit form body to provide a ctools link beneath the body box that 
> results in a modal form being loaded during the creation of a node, if 
> the link is clicked. This works fine, including putting a form in the 
> modal window inside a table (yes, tabular data).
>
> The issue is that the contents of the body text area at that point are 
> needed by my module in order to send back the proper content in the 
> modal window, and I can't seem to get that information back to Drupal. 
> I do -have- the data...I get it via js from the CKEDITOR object with a 
> getdata() call. I suspect there is some way to then give it to ctools 
> to pass back with its ajax call, but cannot find an example. What I've 
> tried, in lieu of that, is to add it onto the url that the link is 
> calling. I discovered that even though ctools is using a click handler 
> to process the link, "onclick" still works, executes first, and does 
> not interfere with or prevent ctools from performing its stuff once 
> finished. So, I changed the link to have an onclick that simply puts 
> the body text into this.sort, making the url be appended by 
> ?body=xxxx    I can't seem to discover if that's viable, and if so, 
> what to do at that point, as it doesn't appear to be in $_GET, $_POST, 
> or available by changing the ctools callback page arguments from 
> array(1) to array(1,2).
>
> Jeff
> -- 
> //


More information about the development mailing list