Created
January 2, 2017 15:37
-
-
Save Sarapulov/fa9ff73c347c141472ea134b7bef54d1 to your computer and use it in GitHub Desktop.
Preset given nested dropdown on Zendesk Help Center with a given value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Preset given nested dropdown on Zendesk Help Center with a given value | |
* | |
* @param {String} field_id (example: 'request_custom_fields_31265065') | |
* @param {String} field_value (example: 'complaint_type_b') | |
*/ | |
function presetNestedDrodown(field_id,field_value){ | |
if (!field_id || field_value === undefined) return; | |
var $field = $('.'+field_id); | |
if ($field && $field.length > 0 && $field.hasClass('string')) { | |
var $input = $field.find('input'), $d = $input.attr('data-tagger'); | |
$d && JSON.parse($d).forEach(function(obj){ | |
if (obj.value === field_value) $input.val(obj.value).closest('.nesty-input').text(obj.label); | |
}); | |
} | |
} | |
presetNestedDrodown('request_custom_fields_23496063','corolla'); | |
// presetNestedDrodown('request_custom_fields_23530886','accord'); | |
// presetNestedDrodown('request_custom_fields_23502577','blahhhh'); | |
// presetNestedDrodown('request_custom_fields_23506078','toyota_ncr'); | |
// presetNestedDrodown('request_custom_fields_31265065','complaint_type_b'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment