Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chosen width issue inside inactive tab container

I am using Chosen library to enable easy filtering on a dropdown control and i am facing one issue now. I am using bootstrap tab control to arrange the items in a form and if i place the Dropdown inside the inactive tab item width of Choosen dropdown is 0 (invisible at all ).

How can i fix this?

@Html.DropDownListFor(model => model.OriginalItem.AuthorId, (SelectList)ViewBag.LicensorList, "Select", new { @class = "chosen-single chosen-default" })
 $('#OriginalItem_AuthorId').chosen({ no_results_text: "Oops, nothing found!" });

This is the way i am using chosen library

like image 512
Sebastian Avatar asked Jan 08 '23 20:01

Sebastian


1 Answers

This is because the width is calculated by Chosen before the dropdown is visible.

There are at least two workarounds:

CSS workaround :

.chosen-container { 
    width: 100% !important; /* desired width */
} 

JS workaround (on Chosen initialization) :

$(".chosen-select").chosen(
    { 
        width: '100%' /* desired width */
    }); 
like image 141
Guy Avatar answered Jan 14 '23 21:01

Guy