Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close the Sidebar upon select of a menu item? #49

Open
dpdonohue opened this issue Aug 11, 2015 · 2 comments
Open

How to close the Sidebar upon select of a menu item? #49

dpdonohue opened this issue Aug 11, 2015 · 2 comments

Comments

@dpdonohue
Copy link

Thanks for this cool project! How can I make the sidebar close when the user selects an option in the menu?

@jspdown
Copy link
Member

jspdown commented Aug 14, 2015

Thanks 😉
Unfortunately, you can't do that easily using an AngularJs binding or such things. However, you probably can use css classes provided by the original semantic-ui. The sidebar component can accept an optional visible class that keep it shown until you remove it.
I'm not 100% sure if it works

<sidebar class="visible">...

By using a ng-class instead of just a class you'll be able to bind this capability to a ng-click

@dpdonohue
Copy link
Author

Thanks I tried using ng-class but could not find the magic formula. This is simpler and works for me (JQuery required)

$scope.closeSidebar = function() {
    $('.ui.sidebar').sidebar('toggle');
};

corresponding HTML:

<div ng-controller="SidebarCtrl">
    <sidebar-link icon="home" title="Home" href="/" ng-click="closeSidebar()"></sidebar-link>
    <sidebar-link icon="rocket" title="Interests" href="interests" ng-click="closeSidebar()"></sidebar-link>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants