0
votes

I have an select2 selectbox which collects data from php and turns them in to options for the select2 selectbox. The issue here is that it won't let me scroll down the list of options for some weird reason. We have a front-end developer who designed everything and inserted the select2 selectbox into the modal. When trying to scroll inside the selectbox.. This is what I get:

https://gyazo.com/21ad4aad44eb67c21419d93dba5fbe6b

I've tried using the docs to find a solution and even tried disabling scroll on whole body and html. None of this worked. Even with body not having scroll enabled, the option would still not let me scroll...

<div class="items">
    <div class="label"><?php _e('Company', 'layback'); ?></div>
    <div class="inputs">
        <select class="select2 task--new-company">
        <option value="0"><?php echo __('Please select...', 'layback'); ?></option>
            <?php
            $aCompanyARGS = array(
            'post_type' => 'company',
            'post_status'=> 'publish',
            'posts_per_page'=> -1,
            );
            $aCompanyQuery = new WP_Query($aCompanyARGS);
            $aCompanyPost = $aCompanyQuery->posts;
            foreach($aCompanyPost as $iCompanyKey => $oCompany)
            {
            ?>
            <option value="<?php echo $oCompany->ID; ?>"><?php echo $oCompany->post_title; ?></option>
            <?php
            }
            ?>
        </select>
    </div>
</div>
1
The Select2 is all default for what I know. Nothing has been modified as far as I know.Lato
do you have the js code where select2 is being applied?Michael Cacciano
Well.. We are using the cdn so... Yea.. But, its default so should be working right out the box. I've just had a meeting with the front-end developer which will look into it.Lato

1 Answers

-1
votes

Just give max-height to what length u want in select2.css. like

<style>
max-height:200px;
overflow-y:scroll;
</style>