Answer the question
In order to leave comments, you need to log in
Rails 5 + Bootstrap simple sidebar - how to keep sidebar position (hidden/ not hidden) when switching between pages?
How to make sidebar menu in Rails 5 application with Bootstrap simple sidebar pattern and keep sidebar position (hidden/ not hidden) when switching between application pages?
Tried to use jquery.cookie.js plugin and cookies in coffee, but it doesn't work (menu opens and closes itself when switching pages):
sidebar.coffee
# Sidebar togle
$(document).on 'turbolinks:load', ->
if $.cookie('sidebar_hidden') is 'hidden'
$('#wrapper').addClass('toggled')
$('#menu-toggle').click (e) ->
e.preventDefault()
# setCookie 'sidebar', 'toggled'
$('#wrapper').toggleClass 'toggled'
if $('#wrapper').hasClass('toggled')
$.cookie 'sidebar_hidden', 'hidden',
expires: 7
path: '/'
else
$.removeCookie 'sidebar_hidden'
return
return
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question