title: jQuery dialog scripts for input val
body: <p>I have a bit of a problem with a jQuery dialog and the way scripts are handled.</p>
  
  <p>In the dialog html, I have</p>
  
  <pre><code>&lt;input id="test"&gt; 
  </code></pre>
  
  <p>If I do </p>
  
  <pre><code>&lt;script type="text/javascript&gt;
     $('#test').val("haha")
  &lt;/script&gt;
  </code></pre>
  
  <p><strong><em>after</em></strong> the input, it shows up. If I put it <strong><em>before</em></strong>, it doesn't work.
  Now the problem is I'm trying to change the value of $('#test') using a click trigger, and I can't!</p>
  
  <pre><code>   $('.testbutton').click(function() { 
            alert();      
            $('#test').val("haha");
      });
  </code></pre>
  
  <p>The alert works, and the initial val replacement works, which means there aren't any duplicate or missing input areas.</p>
  
  <p>The total script as it is now, not working:</p>
  
  <pre><code>&lt;input type="button" class="testbutton" /&gt;
  &lt;input type="text" size="10" id="test" name="test" value=""&gt;
  
   $('#test').val("currentvalue"); // This works
         $('.testbutton').click(function() { 
                alert();      
                $('#test').val("haha");
          });
  </code></pre>
  
  <p><strong>Update</strong>
  The dialog shows the correct value in #test once the dialog is closed and then reopened. Could this be something I'm missing?</p>