I'm playing around with Volt and currently trying to do a simple toggleClass for a sidebar in my Volt app (with no luck). Here is a code sample.
app/main/views/main.html
<:Title>
{{ view main_path, "title", {controller_group: 'main'} }}
<:Body>
<div id="wrapper">
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
<li><a href="#">blah</a></li>
...
</ul>
</div>
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="btn btn-default sidebar-toggler">Toggle Sidebar</div>
<:volt:notices />
{{ view main_path, 'body', {controller_group: 'main'} }}
</div>
</div>
</div>
app/main/assets/js/sidebar.js
$(document).ready(function() {
$(".sidebar-toggler").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
});
When clicking on div.sidebar-toggler
a toggled
class should be added to div#wrapper
... It doesn't, there maybe another way to do this with Volt.
The code above is not working. What's the good Volt way to do this ?