Forums › Forums › Search & Filter Pro › Losing CSS after Ajax reload
Tagged: css
- This topic has 7 replies, 2 voices, and was last updated 5 years, 3 months ago by
Trevor.
-
Trevor(Private) July 3, 2020 at 11:46 am #251296
I suspect that those tags are not being added by our plugin, but instead are being added by one of these:
1. Your theme
2. Another plugin
3. Code you have addedBut, the tags are added at document ready, but the JavaScript that does this does not recognize that our Ajax has fired. The JavaScript that adds the tags needs to be run again at that point, like this:
<script>(function ( $ ) { "use strict"; $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ // call your script or function here }); }(jQuery));</script>
Anonymous(Private) July 3, 2020 at 8:50 pm #251376This didn’t work. I’ve added the script as you suggested in the function.php of my child theme. Any other suggestion?
function enqueue_select2_jquery() {
wp_register_style( ‘select2css’, ‘//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css’, false, ‘1.0’, ‘all’ );
wp_register_script( ‘select2’, ‘//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js’, array( ‘jquery’ ), ‘1.0’, true );
wp_enqueue_style( ‘select2css’ );
wp_enqueue_script( ‘select2’ );
}
add_action( ‘admin_enqueue_scripts’, ‘enqueue_select2_jquery’ );?>
<script>(function ( $ ) {
“use strict”;
$(document).on(“sf:ajaxfinish”, “.searchandfilter”, function(){
// call your script or function here
$(‘.option-tree-ui-select’).select2();
});
}(jQuery));</script><?php
any other suggestion? Not just
Anonymous(Private) July 3, 2020 at 8:57 pm #251380Not just the Select2 classes are missing but entire spans too.
See this code Before Ajax run and after Ajax run.
https://ibb.co/K2MPSkj
https://ibb.co/GkpXZjzTrevor(Private) July 6, 2020 at 5:00 pm #251583Are you trying to add Select2 on the dropdowns? Such as described here:
https://support.searchandfilter.com/forums/topic/css-dropdown-option-active-hover/#post-249903
-
AuthorPosts