bind functions to menu items with jQuery's "each"-

bind functions to menu items with jQuery's "each"-

Dear all,

this might appear like a simple problem, but I am stuck here - and don't know if I am on the right way, after 3 hours of trying and searching... I am still quite new to JavaScript and esp. jQuery, but I hope that this may also help others.

What I simply want to do, is to write a function that binds other functions to menu items on a new web page I develop; in other words: I want to write a function that calls another certain JS function when the user clicks on a particular menu item (with a certain HTML-ID) - and I want this binding to be done based on a JavaScript array, which associates the menu items (with their HTML-ID) with the JS functions.

Here's what I have:
1. I have an array that defines the binding between the menu item's ID and the JS function that shall be called when the item is clicked; currently, this is how it looks:
   var menufunctionality = [
      ['#opendoc', openFile()],
      ['#reregister', DOMprepare()]
   ];

2. And then, the following function is called on DOM-ready to define the binding between menu item and the JS function that shall be executed on a "click"-event on the menu item:
   function menuPrepare(arrayname){
      $.each(arrayname, function(index, item){
         $(item[0]).click(item[1])      ;
      });
   };

where "arrayname" is the name of the array that contains the bound items (i.e., the array named under 1., "menufunctionality").

However, this does not work, and I am pretty sure that my code has a simple flaw in the approach; as said, I have tried a lot and Googled around, but couldn't find a solution for hours. I believe this is very simple - so, please: Could somebody please have a look at it to find the problem???

Thanks a lot !!!

With kind regards ,
Björn[/quote]