Merge pull request #12 from ko31/feature/autocomplete-options

Added autocomplete options hook
This commit is contained in:
rubengc 2019-03-14 17:27:23 +01:00 committed by GitHub
commit ec43076819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -188,7 +188,8 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
wp_localize_script( 'cmb-ajax-search', 'cmb_ajax_search', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'cmb_ajax_search_get_results' )
'nonce' => wp_create_nonce( 'cmb_ajax_search_get_results' ),
'options' => apply_filters( 'cmb_field_ajax_search_autocomplete_options', array() )
) );
wp_enqueue_script( 'cmb-ajax-search' );

View File

@ -8,7 +8,7 @@
var object_type = $(this).attr('data-object-type');
var query_args = $(this).attr('data-query-args');
$(this).devbridgeAutocomplete({
$(this).devbridgeAutocomplete(Object.assign({
serviceUrl: cmb_ajax_search.ajaxurl,
type: 'POST',
triggerSelectOnValidInput: false,
@ -78,7 +78,8 @@
$('input[name=' + field_name + ']').val( suggestion.id ).change();
}
}
});
},
cmb_ajax_search.options));
if( $(this).attr('data-sortable') == 1 ){
$('#' + field_id + '_results').sortable({
@ -116,4 +117,4 @@
$(this).remove();
});
});
})(document, jQuery);
})(document, jQuery);