title: jQuery UI, on accordionactivate determine if panel opening or closing
body: <p>I'm actually working on a jQuery UI accordion and I'm trying to find how I can know when the panel is opening or closing so I can execute a different function for both events.</p>
  
  <pre><code>$("#accordion").bind('accordionactivate', function(event, ui) {
    $(ui.newPanel).find('.itemChildren').empty();
    var index = $("#accordion").accordion("option", "active");
    alert($.isEmptyObject(ui.oldPanel));
    if( index !== false){
      var item = {};
      item[Settings.id_item] = Tree.getTreeItemId(ui.newPanel);
      Tree.displayChildren(item, Settings, Url);
    }
  });
  </code></pre>
  
  <p>I tried to watch if the object is empty: no</p>
  
  <p>I tried to look if the active index is false: only false when the last panel closed</p>
  
  <p>Thanks for your help!</p>