Custom event problem

Custom event problem

Hi all,

I have the following problem:
I'made a jquery plugin which recursively traverse an xml object. What I'm trying to do is to trigger a custom event (for example "traversed") after the xml obj is traversed. this plugin is initiated after a button is pressed. The problem is that when I press the button nothing happens, but when I press it again the event is fired.

  1. return this.each(function() {
  2.       var $this = $(this);
  3.        //The recursive funtion
  4.       treverseXML($data.children(), treeRoot);
  5.        $this.trigger(' traversed');
  6. });