Wrap the rendering code inside a function that the data can be passed to.
This commit is contained in:
parent
d297a1ac62
commit
6cd4ddb71b
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue