Conditions | 1 |
Paths | 1 |
Total Lines | 41 |
Lines | 41 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /** |
||
5 | View Code Duplication | jQuery( document ).ready( function () { |
|
|
|||
6 | |||
7 | jQuery( 'input[name=smbd_meta_term_taxonomy]' ).change(function(){ |
||
8 | jQuery( '.select2-terms' ).select2( { |
||
9 | data: function(){ |
||
10 | return []; |
||
11 | }, |
||
12 | } ); |
||
13 | jQuery( '.select2-terms' ).select2( { |
||
14 | ajax: { |
||
15 | url: ajaxurl, |
||
16 | dataType: 'json', |
||
17 | delay: 250, |
||
18 | data: function ( params ) { |
||
19 | return { |
||
20 | q: params.term, |
||
21 | taxonomy: jQuery('input[name=smbd_meta_term_taxonomy]:checked').val(), |
||
22 | action: 'bd_load_taxonomy_term' |
||
23 | }; |
||
24 | }, |
||
25 | processResults: function ( data ) { |
||
26 | var options = []; |
||
27 | |||
28 | if ( data ) { |
||
29 | jQuery.each( data, function ( index, dataPair ) { |
||
30 | options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } ); |
||
31 | } ); |
||
32 | } |
||
33 | |||
34 | return { |
||
35 | results: options |
||
36 | }; |
||
37 | }, |
||
38 | cache: true |
||
39 | }, |
||
40 | minimumInputLength: 2, // the minimum of symbols to input before perform a search |
||
41 | width: '300px' |
||
42 | } ); |
||
43 | }); |
||
44 | |||
45 | } ); |