Created
November 5, 2018 21:05
-
-
Save staycreativedesign/155ffa753fbdfa7b1e995ade8fafc373 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function reloadSubCategories (category, submenu) { | |
| if (category && submenu) { | |
| $.getScript('/admin/categories/'+ category +'/submenus/'+ submenu +'/subcategories'); | |
| } else { | |
| $('#post_subcategory_id').replaceWith("<select name='post[subcategory_id]' id='post_subcategory_id'></select>" ); | |
| } | |
| } | |
| $('#post_category_id').parent().on('change', '#post_category_id', function(e){ | |
| var cat = this.value; | |
| $('#submenu_category_id').val(cat) | |
| $.getScript('/admin/categories/' + this.value + '/submenus', function(e){ | |
| var submenu = $('#post_submenu_id').val(); | |
| reloadSubCategories(cat, submenu); | |
| }) | |
| }); | |
| $('#post_submenu_id').parent().on('change', '#post_submenu_id', function(e){ | |
| var cat = $('#post_category_id').val(); | |
| var submenu = $('#post_submenu_id').val(); | |
| $('#subcategory_submenu_id').val(submenu); | |
| reloadSubCategories(cat, this.value); | |
| }); | |
| $('#submenu_category_id').parent().on('change', '#submenu_category_id', function(e){ | |
| $('#new_submenu').attr('action', '/admin/categories/' + this.value + '/submenus') | |
| }) | |
| $('#subcategory_submenu_id').parent().on('change', '#subcategory_submenu_id', function(e){ | |
| var cat = $('#post_category_id').val(); | |
| $('#new_subcategory').attr('action', '/admin/categories/' + cat + '/submenus/'+ this.value + '/subcategories') | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment