How to use a lambda function with variables from outside?

How to use a lambda function with variables from outside?

Hello, I've got the following source code:
  1.     function MyMenu()
  2.     {
  3.     menuEntries = [
  4.             { name: 'First', action: function() { alert("First"); } } ,
  5.             { name: 'Second', action: function() { alert("Second"); } } ,
  6.             { name: 'Third', action: function() { alert("Third"); } } ,
  7.         ]
  8.         this.show = function()
  9.         {
  10.             $("#myMenu").append("<ul></ul>");
  11.             for( i = 0; i < menuEntries.length; i++)
  12.             {
  13.                 $("#myMenu ul").append('<li id="pm' + i + '">' + menuEntries[i].name + '</li>');
  14.                 $("#pm" + i).click(function() { menuEntries[i].action(); } );
  15.             }               
  16.         }
  17.     }
I wish to execute the lambda function given at menuEntries[i].action. The list is build, but at a click i've got the error that menuEntries[i] is not defined. What should I do? I think