Ctools modal close breaks page JS I have created a custom module which opens modal with a specific Url Pattern. I'm using the url in a view and it works well. 

The only problem is that I also load another piece of jQuery to create a basic accordion which breaks after the modal has been loaded. The javascript is still called but it toggles twice instead of once.

/**
 *  Implements of hook_menu()
 */
function mymodule_menu() {
  $items['modals/%ctools_js/%'] = array(
      'title' =&gt; 'Product Modal',
      'page arguments' =&gt; array(1, 2),
      'page callback' =&gt; 'mymodule_modal_page',
      'access callback' =&gt; TRUE,
      'type' =&gt; MENU_NORMAL_ITEM,
  );
  return $items;
}
/**
 * A modal static page callback.
 * @param $js
 *   boolean CTools determination whether the user's browser is javascript enabled. 
 * @param $nid
 *   string The node ID of passed as an argument from the hook_menu() path
 * @return
 *   string The contents of the node, that will fill the modal window.
 */
function mymodule_modal_page($js = NULL, $nid = NULL) {
  if ($nid == NULL) {
    return 'No node id was sent. Error.';
  }
  if ($js) {
    ctools_include('modal');
    ctools_include('ajax');

  }
  $node = node_load($nid);
  $contents = render(node_view($node, 'modal', NULL));
  return ctools_modal_render($node-&gt;title, $contents) ;
}

  /**
   * Implements hook_views_pre_render()
   */
  function mymodule_views_pre_render(&amp;$views) {
    if ($views-&gt;name == 'my_view') {
      //add accordion script
        ctools_include('ajax');
        ctools_include('modal');
        ctools_modal_add_js();

        $product_style = array(
          'product-modal-style' =&gt; array(
            'modalSize' =&gt; array(
              'type' =&gt; 'fixed',
              'width' =&gt; 400,
              'height' =&gt; 400,
              'addWidth' =&gt; 10,
              'addHeight' =&gt; 10,
              'contentRight' =&gt; 1,
              'contentBottom' =&gt; 1,
            ),
            'modalOptions' =&gt; array(
              'opacity' =&gt; .9,
              'background-color' =&gt; '#424242',
            ),
            'animation' =&gt; 'fadeIn',
            'modalTheme' =&gt; 'product_modal',
          ),
        );
      drupal_add_js($product_style, 'setting');
      ctools_add_js('product', 'mymodule');
      ctools_add_css('product', 'mymodule');
      drupal_add_js(drupal_get_path('module', 'ukgproducts') . '/js/product_accordion.js','file');      
    }
  } 
  }

  /**
  * Implements hook_theme().
  */
  function ukgproducts_theme() {
    return array(
      'views_view_unformatted__my_view' =&gt; array(
        'variables' =&gt; array('view' =&gt; NULL, 'options' =&gt; NULL, 'row' =&gt; NULL),
        'template' =&gt; 'views-view-unformatted--my_view',
        'base hook' =&gt; 'views_view_unformatted',
        'path' =&gt; drupal_get_path('module', 'mymodule') . '/theme',
      ),
    );
  }


accordion JS

(function($, Drupal)
{
  // Drupal.behaviors is the Drupal onload function:
  Drupal.behaviors.ukgproducts = {
    attach:function()
    {
      $('h2').click(function(e)
      {
        e.preventDefault();
        $(this).closest('.binder').find('.product-list').toggle('slow');
      });
    }
  }
}(jQuery, Drupal));
You should pass the context in and use the once() function to make sure your events are only bound once, and in the right context. Something like:

(function($, Drupal) {
  Drupal.behaviors.ukgproducts = {
    attach: function(context, settings) {
      $('h2', context).once('myaccordian').click(function(e) {
        e.preventDefault();
        $(this).closest('.binder').find('.product-list').toggle('slow');
      });
    }
  };
})(jQuery, Drupal);