WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Buggy select dropdown in widget (5 posts)

  1. miniCarl
    Member
    Posted 2 years ago #

    I have created a widget with a select that lets the user choose a post.
    When the save button is pressed tho, all the <option> elements seem to disappear. The change is saved, but i have to reload the page to see it.

    Here's a video demonstrating the issue:
    http://www.screenr.com/YhLs

    And here's my plugin for you to download:
    The code for the <select> is located in mod6.php lines 111-124.
    select-widget-zip

  2. miniCarl
    Member
    Posted 2 years ago #

    Still looking for a solution on this one

  3. Mark / t31os
    Moderator
    Posted 2 years ago #

    You're self-closing the select tag, here..

    <select class="widefat" id="'.$field_id.'" name="'.$field_name.'" />';

    Which is causing the select to close premature when it tries to re-render..

    It should read..

    <select class="widefat" id="'.$field_id.'" name="'.$field_name.'">';

    Tags that have a closing element(li,ul,select,option...etc..), shouldn't be self-closed, the only elements that need to be self-closed are hr, br and img.. (possibly might be one or two more, but they're the common ones)..

  4. miniCarl
    Member
    Posted 2 years ago #

    Issue resolved, thank you Mark.

  5. Mark / t31os
    Moderator
    Posted 2 years ago #

    You're welcome, and thanks for posting back to let us know.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic