Skip to content

Blank options are very small #65

Closed
@mimopo

Description

Hi! Nice plugin!

But I've found a little bug. If you have a select box with a blank option, for example:

<select name="example">
    <option value=""></option>
    <option value="4">Number 4</option>
    <option value="5">Number 5</option>
</select>

You will get something like this
Captura de pantalla 2013-02-21 a la s 19 39 06

I've fix with this code:

this.$element.find('option').each(function() {
    var optionClass = $(this).attr("class") !== undefined ? $(this).attr("class") : '';
    var text = $(this).text() != '' ? $(this).text() : '&nbsp;';
    if ($(this).parent().is('optgroup')) {
        if ($(this).index() == 0) {
            if ($(this)[0].index != 0) {
                _liA.push(
                    '<dt class="optgroup-div">'+$(this).parent().attr('label')+'</dt>'+
                    '<a tabindex="-1" class="opt '+optionClass+'">'+text+'</a>'
                    );
            } else {
                _liA.push(
                    '<dt>'+$(this).parent().attr('label')+'</dt>'+
                    '<a tabindex="-1" class="opt '+optionClass+'">'+text+'</a>'
                    );
            }
        } else {
             _liA.push('<a tabindex="-1" class="opt '+optionClass+'">'+text+'</a>');
        }
    } else {
        _liA.push('<a tabindex="-1" class="'+optionClass+'">'+text+'</a>');
    }
});

Google Chrome, MacOS X Mountain Lion

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions