| 1 |
|
| 2 |
/** |
| 3 |
* Function that initializes select2 on fields |
| 4 |
* |
| 5 |
* @since v.3.3.4 |
| 6 |
*/ |
| 7 |
function wppb_select2_initialize() { |
| 8 |
jQuery ( '.custom_field_select2' ).each( function(){ |
| 9 |
var selectElement = jQuery( this ); |
| 10 |
var arguments = wp.hooks.applyFilters( 'wppb_select2_initialize_arguments', arguments, selectElement ); |
| 11 |
|
| 12 |
if ( !( 'placeholder' in arguments ) || arguments.placeholder === '' ) { |
| 13 |
arguments.placeholder = jQuery('label[for="' + selectElement.attr('id') + '"]').text(); |
| 14 |
} |
| 15 |
|
| 16 |
selectElement.select2( arguments ).on('select2:open', function(){ |
| 17 |
// compatibility with Divi Overlay |
| 18 |
if( jQuery(selectElement).parents( '.overlay-container' ).length ){ |
| 19 |
jQuery(selectElement).data('select2').dropdown.$dropdownContainer.css( 'z-index', '99999999' ); |
| 20 |
} |
| 21 |
}); |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
jQuery( document ).ready(function() { |
| 26 |
wppb_select2_initialize(); |
| 27 |
}); |