Last active
January 19, 2024 10:04
-
-
Save liranop/d7c6071dc3d68d166d96712fbbbc90d3 to your computer and use it in GitHub Desktop.
add select2 to jetsmartfilter select (php code snippet + js script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function() { | |
jQuery(document).on('jet-smart-filters/inited', function( initEvent ) { | |
// Initialize select2 on the select field | |
jQuery('.jet-select__control').select2({ | |
placeholder: 'Search...', | |
width: '100%', | |
}); | |
}); | |
})(jQuery); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function enqueue_select2_scripts() { | |
// Enqueue Select2 CSS | |
wp_enqueue_style('select2-css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css'); | |
// Enqueue Select2 JavaScript | |
wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js', array('jquery'), '', true); | |
} | |
add_action('wp_enqueue_scripts', 'enqueue_select2_scripts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment