Add autoComplete.js to plugin.

This commit is contained in:
LebCit
2021-01-09 02:54:54 +02:00
parent cfbbaec29a
commit 3c87016095
4 changed files with 173 additions and 22 deletions
+12 -10
View File
@@ -259,16 +259,18 @@ class Full_Screen_Morphing_Search {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
var posts = <?php echo wp_json_encode( array_values( $source ) ); ?>;
jQuery( 'input[name="s"]' ).autocomplete({
source: posts,
minLength: 2,
select: function(event, ui) {
var permalink = ui.item.permalink; // Get permalink from the datasource.
window.location.replace(permalink);
}
});
let posts = <?php echo wp_json_encode( array_values( $source ) ); ?>;
new autoComplete({
data: {
src: posts,
key: ["label"],
cache: false
},
selector: "#morphsearch-input",
onSelection: feedback => {
let permalink = feedback.selection.value.permalink; // Get permalink from the datasource.
window.location.replace(permalink);
}
});
</script>
<?php