Skip to content

Instantly share code, notes, and snippets.

@skipjac
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skipjac/d64465c50f15d1822b0d to your computer and use it in GitHub Desktop.
Save skipjac/d64465c50f15d1822b0d to your computer and use it in GitHub Desktop.
Set default dropdown values in Zendesk Help Center. This is just the code to set the actual value.
<div class="form-field string required request_custom_fields_21631456">
<label for="request_custom_fields_21631456">fav</label>
<input autocomplete="off" data-tagger=data-tagger="{"-":{"id":"","title":"-","selected":true},"pet":{"cat":{"id":"cat","title":"pet::cat"},"dog":{"id":"dog","title":"pet::dog"}},"Dolphin":{"id":"dolphin","title":"Dolphin"},"the fish":{"id":"the_fish","title":"the fish"}}" id="request_custom_fields_21631456" name="request[custom_fields][21631456]" size="0" type="hidden" value="">
<a class="nesty-input" tabindex="0">-</a>
</div>
<script>
//in order to set the value of the field and make it visible set the input value and anchor text
//so this will set the field fav to The fish
$('.request_custom_fields_21631456').one('DOMNodeInserted', function(d){
console.log(d);
$(d.currentTarget).val('the_fish');
$(d.target).text('The Fish');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment