Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity post-form.php jquery code hinting

  • I’d like to do away with the “What’s New?” label, and instead display it inside the textarea of the post form as hint text, so that when the textarea receives focus, the text disappears, and when the textarea loses focus or is empty, the text reappears.

    So far, this is what I’ve come up with, based on a script I often use for the search form on WP client sites. The markup:

    ``

    The jq script:

    `var active_color = ‘#333′;
    var inactive_color = ‘#888′;
    $(“textarea#whats-new”).css(“color”, inactive_color);
    var default_values = new Array();
    $(“textarea#whats-new”).focus(function() {
    if (!default_values[this.id]) {
    default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
    this.value = ”;
    this.style.color = active_color;
    }
    $(this).blur(function() {
    if (this.value == ”) {
    this.style.color = inactive_color;
    this.value = default_values[this.id];
    }
    });
    });`

    It seems to be working great, except when an update is posted (ajax) the form reappears empty (ie. no hint text). when the form next gets a click (ie. focus set and then blurred) the hint text reappears. I’d like the hint text to populate the textarea after an update is posted, but I’m not very knowledgeable about ajax, and unsure if it’s possible. Any suggestions?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.