Skip to content

Instantly share code, notes, and snippets.

@skipjac
Last active August 29, 2015 14:21
Show Gist options
  • Save skipjac/c3534964e4c4b0bd3d2f to your computer and use it in GitHub Desktop.
Save skipjac/c3534964e4c4b0bd3d2f to your computer and use it in GitHub Desktop.
Set the default org zendesk
$(document).ready(function(){
function setDefaultValue(field, setDefault){
$('.'+field).one('DOMNodeInserted', function(d){
var inputTar = $(d.currentTarget).children('select')
var inputNest = $(d.currentTarget).children('a.nesty-input');
var TestObj = inputTar[0];
var TestNest = inputNest[0];
$('#'+TestObj.id).append('<option value="-">-</option>');
$('#'+TestObj.id+' option').removeAttr('selected').filter('[value='+setDefault+']').attr('selected', true);
$(TestNest).text(setDefault);
});
}
//build a JSON object with the ticket field ID as the key to the default tag value you want to set
var listOfDefaults = { 'request_organization_id' : '-'};
for(var key in listOfDefaults){
setDefaultValue(key, listOfDefaults[key]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment