I have a custom form field within a taxonomy. However when a new term/tag has been added I need to clear some values through javascript. How can I do this?
I found the following code snippet in WordPress:
a.post(ajaxurl,a("#addtag").serialize(),function(h)
{
a("#ajax-response").empty();
var f=wpAjax.parseAjaxResponse(h,"ajax-response");
if(!f||f.errors){return}
var g=b.find("select#parent").val();
if(g>0&&a("#tag-"+g).length>0){
a(".tags #tag-"+g).after(f.responses[0].supplemental.noparents)}
else
{a(".tags").prepend(f.responses[0].supplemental.parents)}
a(".tags .no-items").remove();
if(b.find("select#parent")){
var e=f.responses[1].supplemental;
var c="";
for(var d=0;d<f.responses[1].position;d++){c+=" "}
b.find("select#parent option:selected").after('<option value="'+e.term_id+'">'+c+e.name+"</option>")}
// = NOTE THE FOLLOWING LINE =============
a('input[type="text"]:visible, textarea:visible',b).val("")});
// =======================================
return false})});
It clears all the text input fields that are visible, however I have my own custom field that people can select an image and after the image has been selected a hidden input field value is changed with the selected image id and the image is shown through an image object.
However, after the user presses the 'Add new category' button I like to be able to reset the hidden input field and remove the image object.
I like to know when a category has been added so I can reset all that is necessary.