Wrap the rendering code inside a function that the data can be passed to.

This commit is contained in:
George Stephanis 2015-08-07 15:44:10 -04:00
parent 7985aec296
commit f9fd4ada58
1 changed files with 25 additions and 16 deletions

View File

@ -9,11 +9,16 @@
var rowTemplate = wp.template( 'wc-tax-table-row' ),
$tbody = $('#rates');
/**
* Build the table contents.
* @param rates
*/
function renderTableContents( rates ) {
// Blank out the contents.
$tbody.innerHTML = '';
$tbody.empty();
// Populate $tbody with the current page of results.
$.each( data.rates, function ( id, rowData ) {
$.each( rates, function ( id, rowData ) {
$tbody.append( rowTemplate( rowData ) );
} );
@ -28,6 +33,10 @@
source: data.states,
minLength: 3
});
}
renderTableContents( data.rates );
$('.wc_tax_rates .remove_tax_rates').click(function() {
if ( $tbody.find('tr.current').length > 0 ) {