Files
display-featured-image-genesis/includes/js/widget-selector.js
T
Robin Cornett 37cbcc7210 update tax widget to select tax, then term
js needs work
2015-01-05 20:32:18 -05:00

26 lines
700 B
JavaScript

function tax_term_postback( select_id, taxonomy ) {
var data = {
action: 'tax_term_action',
taxonomy: taxonomy
};
jQuery.post(ajax_object.ajax_url, data, function(response) {
// Decode the data received.
var terms = jQuery.parseJSON(response);
// Keep track of what was previously selected
var select_ctrl = jQuery('#' + select_id);
var old_term = select_ctrl.val();
// Clear out the old options, build up the new
select_ctrl.empty();
jQuery.each(terms, function(key, value) {
var new_option = jQuery('<option></option>')
.attr('value', key).text(value);
if (value == old_term) {
new_option.attr('selected', true);
}
select_ctrl.append(new_option);
});
});
}