for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
/**
* Add select2 functionality..
*/
/*global ajaxurl*/
jQuery( document ).ready( function () {
* Normal select2.
jQuery( '.select2-taxonomy' ).select2( {
width: '300px'
} );
* Enable AJAX for Taxonomy Select2.
jQuery( '.select2-taxonomy-ajax' ).select2( {
ajax: {
url: ajaxurl,
dataType: 'json',
delay: 250,
data: function ( params ) {
return {
q: params.term,
taxonomy: jQuery( this ).attr( 'data-taxonomy' ),
action: 'bd_load_taxonomy_term'
};
},
processResults: function ( data ) {
var options = [];
if ( data ) {
jQuery.each( data, function ( index, dataPair ) {
options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } );
}
results: options
cache: true
minimumInputLength: 2, // the minimum of symbols to input before perform a search