Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DDSlick with Gravity Forms
$('.gfield select').each(function(e) {
// Hide the select element
$(this).css('display', 'none');
// clone the select element
clone = $(this).clone();
// append the cloned select after the first select
$(this).after(clone);
// store the original select ID
var selectID = $(this).attr('id');
// Call ddslick on the cloned select
$(clone).ddslick({
onSelected: function(data) {
// onSelected get the length of value of the selected option
var value = $('#' + selectID + ' .dd-selected-value').val().length;
// if the value is set (exists)
if (value > 0) {
// update the original select element with the chosen value. Fire a change to make it run condtional logic
$('select#' + selectID)
.val(data.selectedData.value)
.change();
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment