Last active
February 3, 2017 20:16
-
-
Save sepehr125/239f59e885f92115c517 to your computer and use it in GitHub Desktop.
This file contains 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
jQuery( document ).ready( function( $ ) { | |
$('#s').autocomplete({ | |
serviceUrl: '/wp-admin/admin-ajax.php?action=autocompleteCallback', | |
dataType: 'json', | |
paramName: 'term', | |
transformResult: function(response) { | |
return { | |
suggestions: $.map(response.results, function(dataItem) { | |
return { value: dataItem.title, data: dataItem.url }; | |
}) | |
}; | |
}, | |
onSelect: function(suggestion) { | |
window.location.replace(suggestion.data); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment