jquery variable scope issue
<p>I have the following jquery code:</p>

<pre><code>$(document).ready(function(){
    var request_text;
    request_text = "Hello my name is " + $('#name').val() + ", and I would like to join the birthday surprise for &lt;%= get_current_board.bp_name.capitalize %&gt;.\n\n" +
    "Could you please send me an invitation so that I can participate.\n\nThank you very much. \n\n" + $('#name').val();

    $('textarea').text(request_text);

    $('#name').keyup(function() {
        $('textarea').text(request_text);
        });
    });
</code></pre>

<p>It works for the document.ready part but not for the keyup.  I thought it was a scope problem but I can't seem to get it to work.</p>

<p>If I do the following it works:</p>

<pre><code> $('#name').keyup(function() {
        request_text = "Hello my name is " + $('#name').val() + ", and I would like to join the birthday surprise for &lt;%= get_current_board.bp_name.capitalize %&gt;.\n\n" +
        "Could you please send me an invitation so that I can participate.\n\nThank you very much. \n\n" + $('#name').val();
        $('textarea').text(request_text);
        });
</code></pre>

<p>but I don't want to repeat code.</p>

<p>Any ideas?</p>
