$(function () {
$('li.mainmenu-item[data-request]').on('click', function (e) {
e.preventDefault(); // Prevent default click behavior
var requestHandler = $(this).attr('data-request'); // Get the request handler name
// Trigger an AJAX request using OctoberCMS framework
$(this).request(requestHandler);
});
});
This is a functional example that you can adapt as needed. If necessary, you can also override the modules\backend\layouts\_submenu_items.php partial.
Hi @apinard
thanks for the suggestion.
Sounds like it is worth trying it out.
Would there be a way to get an existing controller context so I can just reuse the ajax Handler and the context (formModel etc, …) as I want show a popup with a formWidget.
I dont see how I can inject a js file since this side menu can be called from “anywhere” in my plugin.
because it’s a link and not attached to a specific controller.
Event::listen('backend.page.beforeDisplay', function ($controller, $action, $params) {
$controller->addJs('/plugins/voilaah/skillup/assets/js/backend/add_menu.js');
$controller->addDynamicMethod('onCreateCourseWizard', function () {
$coursesController = new Courses; // an internal plugin controller
return $coursesController->index_onCreateForm();
});
});
the popup display the loader in loop and the form widget, which is build in the method index_onCreateForm that works fine when called from the list_toolbar, is not displayed in the popup.
no error, no log anywhere. What am I missing here ?