Hello Philip
Cool business site you have!
First let me say that I think this plugin is AMAZING!
thanks glad you like it, would spare a minute and put that into a review?
Any ideas why it’s not working?
Actually it is working, but hidden below the modal.
The problem is that the Select2 plugin stores its listing in the <body> tag and not in the actual list parent element. When you create a modal the list actually renders but is hidden below.
There is 2 way to tackle this, you can use css to force the listing above:
.select2-container--open {
z-index: 20007;
}
or you can stop the plugin from initiating your select2 fields and instead use a custom script to force the select2 list to attach itself to the parent element.
The 2nd method is the select2 recommended way to ensure a clean display on all screens, but I found the simple css rule above to work just fine in the past.
Cool business site you have!
Thanks, that much appreciated; I had loads of fun shooting videos for each of the weather conditions (had to wait 12 months to see the snow video appear haha).
Actually it is working, but hidden below the modal.
Doh! why didn’t I think of that before contacting you! Thanks for the css solution, I’ve added it to my child-theme css and everything is working perfectly! I’ve had a quick look ad the ‘recommended’ way but not sure how I’d implement it so will stick with the css method for now.
Thanks for your uber fast reply, a donation (as a token of my thanks) is on it’s way.
(had to wait 12 months to see the snow video appear haha).
nice, the effect is very creative!
way but not sure how I’d implement
ah, yes! I forgot to mention that there is filter you can hook to disable the plugin auto-initialisation of the select2 field,
add_filter( 'cf7_2_post_filter_cf7_delay_select2_launch', '__return_true');
you then need to load your own script on the page, and fire the select2 initialisation once the form has been initialised by the plugin,
add_filter('cf7_2_post_form_append_output', 'append_my_script', 10, 4);
function append_my_script($output, $attr, $nonce, $cf7form_key){
if(!isset($attr['id'])){
return $output;
}
$cf7_id = $attr['id'];
if(19 == $cf7_id){ //check this is your form
$output .= '<script type="text/javascript">';
$output .= '(function( $ ) {';
$output .= ' //fire your script once the form nonce event is triggered';
$output .= ' $(document).on("'.$nonce.'", $("div#'.$nonce.' form.wpcf7-form"), function() {';
$output .= ' var cf7Form = $("div#'.$nonce.' form.wpcf7-form");';
$output .= ' ... //your custom scripting';
$output .= '});';
$output .= '})( jQuery );';
$output .= '</script>';
}
return $output;
}
It may still come in handy in the future to further leverage select2 functionality.
PS: If you use the CF7 plugin on a regular basis, you may want to explore the Smart Grid-layout Design extension which really transforms the capabilities of the plugin.
Awesome! Thanks for adding the information, it’s handy to know just in case.