ajax_command_invoke Question related to Commerce + Colorbox + AJAX I am displaying a Drupal Commerce node with AJAX add to cart functionality in a popup, with the Colorbox Node module.  In my custom form callback, I have the following code.

// Form callback function
function ajax_module_form($form, &amp;$form_state){
  drupal_add_js(drupal_get_path('module','colorbox' . '/colorbox.js'));
  $commands = array();

  $commands[] = ajax_command_invoke('colorbox-node', 'colorbox.close');

  return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
}


I am trying to use Drupal's ajax_command_invoke to close the Colorbox window after AJAX form submission is complete, but cant seem get it to work. I tried 'parent.colorbox.close' as well but doesnt seem to work. The colorbox link has iframe and sample link is -

example.com/node/45434345?width=500&amp;height=500&amp;iframe=true and link class is .colorbox-node

Also the Colorbox module setting - invoke on all pages is also active.

Any lead/help is greatly appreciated.
I'm editing my answer to directly address your question first:

ajax_command_invoke takes a css selector as its first argument.  

 node-colorbox


isn't a css selector (or at the very least, not a valid one).

In addition, ajax_command_invoke does not allow for the execution of arbitrary javascript, but only allows for triggering registered jQuery events.  If you want to create a custom jQuery event for colorbox, you will have to manually create it and attach it to the colorbox object, using Drupal.behaviors.

http://www.sitepoint.com/jquery-custom-events/ should get your started.

Colorbox seems like it might be a good solution for your use-case, but it really isn't.  If you want a good floating window with ajax forms and automatic closure, using the chaos tools modal system is a better bet.  It supports what you're looking for right out of the box and makes working with forms easy.  In addition, almost everyone uses ctools, as it is a dependency for many different modules.

http://deeson-online.co.uk/labs/insert-form-pop-modal-ctools-and-drupal-7 should get you started.