Chosen harvesthq resize width dynamically

前端 未结 12 1599
渐次进展
渐次进展 2020-12-30 03:49

How can you have a harvesthq Chosen dropdown with a dynamic width style?

By default it has a fixed width and if you try to modify it with CSS you will have several p

12条回答
  •  北海茫月
    2020-12-30 04:13

    Here is the simple why I did it.

    JS:

    // Create Chosen Select Menus
    setUpSelectMenus();
    
    // Reset Chosen Select Menus when window changes size
    window.addEventListener( "resize", function() { setUpSelectMenus(); } );
    
    /**
     * Settings for Default Chosen Select Menus
     */
    function setUpSelectMenus(){
    
        $( '.chosen-select' )
            .chosen( "destroy" ) // Need this to make responsive
            .chosen(
                {
                    allow_single_deselect   : true,
                    disable_search_threshold: 10
                }
            );
    }
    

提交回复
热议问题