Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save stephenscaff/40b32bb6b5afeb91133b to your computer and use it in GitHub Desktop.

Select an option

Save stephenscaff/40b32bb6b5afeb91133b to your computer and use it in GitHub Desktop.
Remove placeholder/ first option from a DropKick.js select and corresponding unordered list output. Using DropKick in a rails app featuring a filter bar, needed to ensure select placeholders via 'prompt" would not be selectable. Since Dropkick.js makes an unordered list from selects, have to ensure that both the first select option and ul list i…
/*----------------------------------------------
--Remove Prompt after change
----------------------------------------------- */
//target all styled selects and their generated unordered list
$('.dk-drops').change(function(){
//Remove the first select option & it's corresponding generated list item
$(".dk_options_inner li:first-child").remove();
$(this).find('option:first').remove();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment