{"action":"created","issue":{"url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/738","labels_url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/738/labels{/name}","comments_url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/738/comments","events_url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/738/events","html_url":"https://github.com/almasaeed2010/AdminLTE/issues/738","id":111540668,"number":738,"title":"Sidebar toggle","user":{"login":"erchohke","id":15135074,"avatar_url":"https://avatars.githubusercontent.com/u/15135074?v=3","gravatar_id":"","url":"https://api.github.com/users/erchohke","html_url":"https://github.com/erchohke","followers_url":"https://api.github.com/users/erchohke/followers","following_url":"https://api.github.com/users/erchohke/following{/other_user}","gists_url":"https://api.github.com/users/erchohke/gists{/gist_id}","starred_url":"https://api.github.com/users/erchohke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erchohke/subscriptions","organizations_url":"https://api.github.com/users/erchohke/orgs","repos_url":"https://api.github.com/users/erchohke/repos","events_url":"https://api.github.com/users/erchohke/events{/privacy}","received_events_url":"https://api.github.com/users/erchohke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-15T03:57:45Z","updated_at":"2015-10-16T18:38:23Z","closed_at":null,"body":"hi,\r\nim using adminlte 2.3.0 version , and currently having an issue with the sidebar.\r\nWhen i toggle the sidebar, it collapses but when i opening a new page. the sidebar opened again.\r\n![sidebarcol](https://cloud.githubusercontent.com/assets/15135074/10504514/4095e5aa-732b-11e5-814f-a0135605be2a.png)\r\nthis is the pic when it collapsed. \r\nthen when  i open a new page. the side bar should be still collapsed but it dont\r\n![sidebaropen](https://cloud.githubusercontent.com/assets/15135074/10504524/60888606-732b-11e5-94b5-b44f0d65007f.png)\r\nwhat should i do to fix this ? thanks any reply would be really appreciated.\r\n\r\nand also, where do i i find the variables used to determine the saved themes color (red in this picture)"},"comment":{"url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/comments/148800231","html_url":"https://github.com/almasaeed2010/AdminLTE/issues/738#issuecomment-148800231","issue_url":"https://api.github.com/repos/almasaeed2010/AdminLTE/issues/738","id":148800231,"user":{"login":"ivantcholakov","id":1438104,"avatar_url":"https://avatars.githubusercontent.com/u/1438104?v=3","gravatar_id":"","url":"https://api.github.com/users/ivantcholakov","html_url":"https://github.com/ivantcholakov","followers_url":"https://api.github.com/users/ivantcholakov/followers","following_url":"https://api.github.com/users/ivantcholakov/following{/other_user}","gists_url":"https://api.github.com/users/ivantcholakov/gists{/gist_id}","starred_url":"https://api.github.com/users/ivantcholakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivantcholakov/subscriptions","organizations_url":"https://api.github.com/users/ivantcholakov/orgs","repos_url":"https://api.github.com/users/ivantcholakov/repos","events_url":"https://api.github.com/users/ivantcholakov/events{/privacy}","received_events_url":"https://api.github.com/users/ivantcholakov/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T18:38:22Z","updated_at":"2015-10-16T18:38:22Z","body":"@erchohke\r\n\r\nI use AdminLTE v2.1.2, heavily customized CodeIgniter (PHP) and jQuery, I hope you will be able to adapt code I've got. The idea is what is important.\r\n\r\n1- Within your main HTML template, at the bottom place the following event handler, it contains the AJAX request I've mentioned:\r\n\r\n```javascript\r\n    <script type=\"text/javascript\">\r\n    //<![CDATA[\r\n\r\n    $(function() {\r\n\r\n        $('#sidebar_toggle').on('click', function(e) {\r\n\r\n            var body = $('body');\r\n            var state = '';\r\n\r\n            if (body.hasClass('sidebar-collapse')) {\r\n                state = 'sidebar-collapse';\r\n            }\r\n\r\n            $.ajax({\r\n                type: 'post',\r\n                mode: 'queue',\r\n                url: '<?php echo site_url('main-sidebar/toggle-ajax'); ?>',\r\n                data: {\r\n                    state: state\r\n                },\r\n                success: function(data) {\r\n\r\n                }\r\n            });\r\n        });\r\n\r\n    });\r\n\r\n    //]]>\r\n    </script>\r\n\r\n```\r\n\r\n2- A controller that should respond to the AJAX request should be created, it stores the sidebar state:\r\n\r\n```php\r\n<?php defined('BASEPATH') OR exit('No direct script access allowed.');\r\n\r\nclass Toggle_ajax_controller extends Base_Ajax_Controller {\r\n\r\n    public function __construct() {\r\n\r\n        parent::__construct();\r\n\r\n        $this->load->library('session');\r\n    }\r\n\r\n    public function index() {\r\n\r\n        $this->output->set_header('Content-Type: application/json; charset=utf-8');\r\n\r\n        $state = (string) $this->input->post('state');\r\n\r\n        if ($state == '') {\r\n\r\n            $state = null;\r\n            $this->session->unset_userdata('main_sidebar_state');\r\n\r\n        } else {\r\n\r\n            $this->session->set_userdata('main_sidebar_state', $state);\r\n        }\r\n\r\n        $this->output->set_output(json_encode(array('state' => $state)));\r\n    }\r\n\r\n}\r\n```\r\n\r\n3- When a page loads, it needs to read from the stored session variable the state. When sidebar is collapsed then the body tag should have the attribute 'sidebar-collapse', otherwise not. Here is how my template starts:\r\n\r\n```php\r\n<?php defined('BASEPATH') OR exit('No direct script access allowed');\r\n\r\necho html_tag('lang=\"'.$this->lang->code().'\" dir=\"'.$this->lang->direction().'\"');\r\nfile_partial('default_head');\r\necho body_tag('id=\"page-top\" class=\"skin-purple'.' '.$this->session->userdata('main_sidebar_state').'\"');\r\n```\r\n\r\nSo, when the sidebar is collapsed the following body-tag is rendered:\r\n\r\n```html\r\n<body class=\"skin-blue sidebar-collapse\" id=\"page-top\">\r\n```\r\n\r\notherwise:\r\n\r\n```html\r\n<body class=\"skin-blue\" id=\"page-top\">\r\n```\r\n\r\nThis is it."}}