jQuery document.ready fire when modal popup reopened?
<p>I'm using jQuery to display a counter above a textbox of how many characters the user has entered and how many they have left. It does this by updating the <code>.text()</code> of a <code>span</code> above the textbox.</p>

<p>So in <code>$(document).ready</code> I initially set the span to the maxlength of the textbox and then onkeyup it is updated.</p>

<p>It's working very well, however when the textbox is inside a ASP.NET ModalPopup from the ajax control library, I have observed that if the ModalPopup closes and then is reopened, the <code>$(document).ready</code> doesn't appear to re-fire so the initial number of characters remaining isn't updated (although when you start typing again, it works as expected)</p>

<p>(In my example there is a DropDownList inside the ModalPopup with AutoPostBack="true", and after postback the <code>.Show()</code> method is called on the popup extender to make it remain visible)</p>

<p>When I've come across similar things I've been directed to use the <code>.live</code> event in jQuery which I have done for the keyup handler. Is there some similar way to solve the problem for the initial setting of the <code>span</code>?</p>

<p>ASP.NET markup:</p>

<pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="cMain" Runat="Server"&gt;
    &lt;p&gt; 
        Enter some text (&lt;span id="countRemain"&gt;&lt;/span&gt; characters remaining) &lt;br /&gt;
        &lt;asp:TextBox runat="server" id="txtCounterTest" MaxLength="100" CssClass="input mediumField CountMe" /&gt;
    &lt;/p&gt;
&lt;/asp:Content&gt;
</code></pre>

<p>and associated jQuery:</p>

<pre><code>$(document).ready(function () {
    $(".CountMe").each(function () {
        var txtBoxContent = ($(this).val());
        var txtBoxMaxLength = ($(this).attr("maxlength"));

        var length = (txtBoxMaxLength - txtBoxContent.length) + '/' + txtBoxMaxLength;

        //alert(length);

        $(this).parent().find("#countRemain").text(length);
    });

    $(".CountMe").live("keyup", function (event) {
        var txtBoxContent = ($(this).val());
        var txtBoxMaxLength = ($(this).attr("maxlength"));

        var length = (txtBoxMaxLength - txtBoxContent.length) + '/' + txtBoxMaxLength;

        //alert(length);

        $(this).parent().find("#countRemain").text(length);
    });
});
</code></pre>
