From 37f10c18cd51f69701361059e9dbe6cefbe5feaf Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Fri, 7 Aug 2015 15:29:56 -0400 Subject: [PATCH] Reposition when autocomplete is triggered. Also, instead of searching through the whole dom, only search in the tbody. --- .../admin/settings-views-html-settings-tax.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/assets/js/admin/settings-views-html-settings-tax.js b/assets/js/admin/settings-views-html-settings-tax.js index f69dbb67632..348b425db79 100644 --- a/assets/js/admin/settings-views-html-settings-tax.js +++ b/assets/js/admin/settings-views-html-settings-tax.js @@ -12,6 +12,18 @@ $.each( data.rates, function ( id, rowData ) { $tbody.append( rowTemplate( rowData ) ); } ); + + // Initialize autocomplete for countries. + $tbody.find( 'td.country input' ).autocomplete({ + source: data.countries, + minLength: 3 + }); + + // Initialize autocomplete for states. + $tbody.find( 'td.state input' ).autocomplete({ + source: data.states, + minLength: 3 + }); }); $('.wc_tax_rates .remove_tax_rates').click(function() { @@ -97,13 +109,4 @@ $(this).attr( 'name', $(this).attr( 'data-name' ) ); }); - $( 'td.country input' ).autocomplete({ - source: data.countries, - minLength: 3 - }); - - $( 'td.state input' ).autocomplete({ - source: data.states, - minLength: 3 - }); })(jQuery, htmlSettingsTaxLocalizeScript, wp);