Skip to content

Commit

Permalink
Merge pull request #13 from CottaCush/fix/dependent-dropdown-asset
Browse files Browse the repository at this point in the history
Fix: Remove dependence on HTML structure
  • Loading branch information
olajideoye authored Oct 6, 2017
2 parents 989e444 + f2dc1fe commit 0d8b3c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/public-assets/js/dependent-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
*
*/
$(function () {
var dropdown_selector = 'select[data-dependent-dropdown]';

/**
* Clears and reloads the child drop-down for a parent drop-down
* @event change
*/
$(document).on('change', 'select[data-dependent-dropdown]', function () {
$(document).on('change', dropdown_selector, function () {
var $element = $(this);

// Remove a dependent drop-down child if it already exists
$element.next('.dependent-dropdown-child').remove();
$(dropdown_selector).slice ( $(dropdown_selector).index( $element ) + 1).remove();

$.ajax({
type: 'POST',
Expand Down

0 comments on commit 0d8b3c8

Please sign in to comment.