title: jQuery UI Dialog buttons within an if statement
body: <p>I have the following function, which brings up a menu of fish that can be bought within</p>
  
  <pre><code>.dialog({
      title: "Fish Store",
      resizable: true,
      draggable: true,
      modal: true,
      buttons: {
          "Beard Fish($30)": function() {
              if (cash &gt;= 30)
              {
                  fish1 =1;
                  fish1Swim1();
                  cash -= 30;
                  setNav();
                  $( this ).dialog( "close" );
              }
              else
              {
                  notEnoughCash();
              }
          },
          "Clown Fish($50)": function() {
              if (cash &gt;= 50) 
              {
                  fish2 = 1;
                  fish2Swim1();
                  cash -= 50;
                  setNav();
                  $( this ).dialog( "close" );
              }
              else 
              {
                  notEnoughCash(); 
              }
          },
          "Neon Fish($75)": function() {
              if (cash &gt;= 75) 
              {
                  fish3 = 1;
                  fish3Swim1();
                  cash -= 75;
                  setNav();
                  $( this ).dialog( "close" );
              }
              else
              { 
                  notEnoughCash(); 
              }
          }
      }
  });
  </code></pre>
  
  <p>I want to edit the function so that buttons can be turned on and off based on if variables (fish1, fish2, &amp; fish3).</p>
  
  <p>So I try to make the following change...</p>
  
  <pre><code>buttons: { 
      if(fish1=0)
      {
          "Beard Fish($30)": function() {
              if (cash &gt;= 30) 
              {
                  fish1 =1;
                  fish1Swim1();
                  cash -= 30;
                  setNav();
                  $( this ).dialog( "close" );
              }
              else 
              { 
                  notEnoughCash(); 
              }
          },
     }
  </code></pre>
  
  <p>but my text-edit says the syntax is invalid, how can I make this work?</p>