// Get module hook classnames when a module is selected in the creation dialog $('#module_id').change(function(ev) { var $classnameSelect = $('#classname'); $classnameSelect.html('').prop('disabled', true); var moduleId = $("#module_id").val(); $.ajax({ url : "{url path="/admin/module-hooks/get-module-hook-classnames"}/" + moduleId, success : function(data) { $classnameSelect.empty(); if (data.length == 0) { $classnameSelect.append( '' ) } else { $(data).each(function(idx, item) { $classnameSelect.empty().append( '' ) }); $classnameSelect.prop('disabled', false); // For initializing the selected option when editing a module hook if ('' != currentClassname) { $classnameSelect.val(currentClassname); currentClassname = ''; } } // Get related methods $('#classname').change(); }, error : function() { alert("{intl l='Sorry, an error occurred, please try again.'}"); } }) }); // Get module hook methods when a module is selected in the creation dialog $('#classname').change(function(ev) { var $methodSelect = $('#method'); var moduleId = $("#module_id").val(); var classname = $("#classname").val(); $methodSelect.prop('disabled', true); if ('' == classname) { $methodSelect.empty(); return; } $methodSelect.html(''); $.ajax({ url : "{url path="/admin/module-hooks/get-module-hook-methods"}/" + moduleId + '/' + classname, success : function(data) { $methodSelect.empty(); if (data.length == 0) { $methodSelect.append( '' ) } else { $(data).each(function(idx, item) { $methodSelect.append( '' ) }); $methodSelect.prop('disabled', false); // For initializing the selected option when editing a module hook if ('' != currentMethod) { $methodSelect.val(currentMethod); currentMethod = ''; } } }, error : function() { alert("{intl l='Sorry, an error occurred, please try again.'}"); } }) });