Created
January 25, 2016 23:30
-
-
Save Shelob9/152da768036c497e99d4 to your computer and use it in GitHub Desktop.
Simple select2 for posts via WP API
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
$( '#search' ).select2( { | |
ajax: { | |
url: API.root + '/wp/v2/posts', | |
processResults: function( data, page ) { | |
console.log( data ); | |
return { | |
//do something results | |
} | |
}, | |
cache: false, | |
data: function ( params ) { | |
var query = { | |
search: params.term, | |
page: params.page | |
}; | |
return query; | |
}, | |
delay: 250, | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment