# profile-builder/3.9.6/front-end/default-fields/select2/select2.js

User Profile Builder – Beautiful User Registration Forms, User Profiles &amp; User Role Editor, version 3.9.6. 23 lines.

- Page: https://pluginprobe.com/plugins/profile-builder/3.9.6/code/front-end/default-fields/select2/select2.js
- Raw: https://pluginprobe.com/plugins/profile-builder/3.9.6/raw/front-end/default-fields/select2/select2.js
- Modified: 2022-10-05T06:23:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/profile-builder/3.9.6/code/front-end/default-fields/select2/select2.js#L10-L20`.

```javascript

/**
 * Function that initializes select2 on fields
 *
 * @since v.3.3.4
 */
function wppb_select2_initialize() {
    jQuery ( '.custom_field_select2' ).each( function(){
        var selectElement = jQuery( this );
        var arguments = selectElement.attr('data-wppb-select2-arguments');
        arguments = JSON.parse( arguments );
        selectElement.select2( arguments ).on('select2:open', function(){
            // compatibility with Divi Overlay
            if( jQuery(selectElement).parents( '.overlay-container' ).length ){
                jQuery(selectElement).data('select2').dropdown.$dropdownContainer.css( 'z-index', '99999999' );
            }
        });
    });
}

jQuery( document ).ready(function() {
    wppb_select2_initialize();
});
```
