title: jquery-ui buttons as array - example of setting label?
body: <p><em>See Edit below initial question for a revised version of the original problem</em></p>
  
  <p>Using a jquery-ui dialog I want to be able to specify the label on the button dynamically.</p>
  
  <p>To do this I'm specifying an array of buttons like this :</p>
  
  <pre><code>var arrbuttons = {};
  arrbuttons.cancel = function() { alert('test1');};
  arrbuttons.update = function() { alert('test2');};
      $(function() {
        $( "#dialog" ).dialog({buttons: arrbuttons});
      });
  </code></pre>
  
  <p>I got that from <a href="https://stackoverflow.com/questions/1357281/jquery-ui-dialog-buttons-from-variables/1357295#1357295">this stackoverflow answer</a> and it works fine as far as it goes.</p>
  
  <p>What I would like to know now is how I can setup the array so the label of each button is specified for each element of 'arrbuttons'.</p>
  
  <p><a href="http://jqueryui.com/demos/dialog/" rel="nofollow noreferrer">The jquery-ui documentation</a> shows how to do this with an inline array like this :</p>
  
  <pre><code>$( ".selector" ).dialog({ buttons: [
      {
          text: "Ok",
          click: function() { $(this).dialog("close"); }
      }
  ] });
  </code></pre>
  
  <p>But there's no example in the jquery doco which corresponds <a href="https://stackoverflow.com/questions/1357281/jquery-ui-dialog-buttons-from-variables/1357295#1357295">to the answer</a> I'm basing my attempt on.</p>
  
  <p>Anyone know ?</p>
  
  <hr>
  
  <p>OK I've now worked on this a little more. By doing the following I can specify the text of the buttons. The trouble is the function part no longer works (ie the buttons are labelled 'wow!' and 'kapow!' but when you click on them nothing happens.</p>
  
  <pre><code>var arrbuttons = {};
  arrbuttons.cancel = {click: "function() { alert('test1');}", text:"wow!"};
  arrbuttons.update = {click: "function() { alert('test2');}", text:"kapow!"};
  $(function() {
      $( "#dialog" ).dialog({buttons: arrbuttons});
  });
  </code></pre>
  
  <p>Any ideas of how to do this ?</p>