Closed janimattiellonen closed 10 years ago
Hey Janimatti,
You may need to catch the click events and stop them from propagating or performing default behaviour. Try this:
$('.my-button').on('click', function(event) {
event.stopPropagation();
event.preventDefault();
mySlidebars.open('left');
});
Let me know if that helps!
Thanks, Adam
Hi,
I tried your code now. It works better. Actually the button should no be named "Open menu". Instead it should probably act more like a toggle that can be used for showing and hiding the menu.
Unfortunately your code does not hide the menu if clicked again. Are there methods for programmatically closing the menu and checking if the menu is already open? I could use those.
Altrnatively there could be some kind of toggle feature built-in.
Hey,
Great to hear that worked. Yes, there is a toggle you can use like:
$('.my-button').on('click', function(event) {
event.stopPropagation();
event.preventDefault();
mySlidebars.toggle('left');
});
All of the API uses can be found at http://plugins.adchsm.me/slidebars/usage.php#api
I hope that helps,
Thanks, Adam
Thanks, works like a charm!
Excellent, glad to hear you've got it going!
Hi,
if I click on the button to open the menu and click it again, then clicking the button a third time won't open the menu anymore. If I continue clicking on the button, the menu is opened for a while and closed automatically - with jerkish movements.
The problem seems to go away if I in click somewhere else in the browser and then again on the button.
Code that I use:
$('.my-button').on('click', function() { mySlidebars.open('left'); });