Close Dashboard Sidebar Automatically On Custom Single Page View
PermalinkJust kidding thats how I get smarter.
So I wanted to close the dashboard sidebar automatically whenever the user navigates to my single page in the dashboard.
The code that runs the open and close event of the dashboard side panel is found in the dashboard theme footer.php:
$(function() { $('a[data-launch-panel=dashboard]').on('click', function() { setTimeout(function() { // needs a moment var panel = ConcretePanelManager.getByIdentifier('dashboard'); if (panel.isOpen) { $.cookie('dashboardPanelStatus', 'open', {path: '<?php echo DIR_REL?>/'}); } else { $.cookie('dashboardPanelStatus', 'closed', {path: '<?php echo DIR_REL?>/' }); } }, 500); }); });
jQuery has a cool function that will execute an event from code instead of it actually happening, so I can execute the dashboard button being clicked from jQuery whenever my single page is opened:
$(function() { $('a[data-launch-panel=dashboard]').triggerHandler('click'); });
And thats it, I've got that code registered as an asset on my single page view, and it causes the dashboard side bar to close upon visiting my single page!
So new question, how to have my single page view initiate the sidebar to close automatically?