Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Created November 5, 2018 17:45
Show Gist options
  • Save staycreativedesign/698d802bd3fff19206eb5b1c062fb05b to your computer and use it in GitHub Desktop.
Save staycreativedesign/698d802bd3fff19206eb5b1c062fb05b to your computer and use it in GitHub Desktop.
how can i better write this, if post_category id change then it goes down to change submenu and subcategory, if submenu is changed it changes the subcategory
$('#post_category_id').change(function(e){
var cat = this.value
$.getScript('/admin/categories/' + this.value + '/submenus', function(e){
var submenu = $('#post_submenu_id').val();
if (submenu == null) {
} else {
$.getScript('/admin/categories/' + cat + '/submenus/' + submenu + '/subcategories')
}
})
})
$('#post_submenu_id').change(function(e){
var cat = $('#post_category_id').val();
console.log(this.value)
console.log('foo')
if (this.value == null) {
} else {
$.getScript('/admin/categories/' + cat + '/submenus/' + this.value + '/subcategories')
}
})
@staycreativedesign
Copy link
Author

I am currently having a problem whenever the category is changed I change the submenu but the submenu change isnt fired...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment