pjsikora / select-box

Automatically exported from code.google.com/p/select-box
1 stars 0 forks source link

Recommendation to make select-box width dynamic based on width of select being replaced #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In the function

_attachSelectbox: function (target, settings) {

starting on line 148, you can add a quick check to see how wide is the select 
box you are replacing, allowing for a more consistent form element replacement:

            //get width of the select box that is the target
            //if the select box does not have a width defined, and is not visible
            //on the page, it will return 0.

        var theWidth = $(target).outerWidth();
        var toggleWidth = $("#sbToggle_" + inst.uid).outerWidth();

            //let's check to see if there is a width that we can apply
            //to the new replacement elements.
            //if the original element did not have a width, then the new
            //elements will default to the width defined in the .css file

    if (theWidth) {
        sbHolder.css({'width':theWidth + toggleWidth});
        sbSelector.css({ 'width': theWidth + toggleWidth });
    }

Original issue reported on code.google.com by i...@somadg.com on 29 Aug 2011 at 9:19