{"action":"opened","issue":{"url":"https://api.github.com/repos/philippfrenzel/yii2fullcalendar/issues/36","labels_url":"https://api.github.com/repos/philippfrenzel/yii2fullcalendar/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/philippfrenzel/yii2fullcalendar/issues/36/comments","events_url":"https://api.github.com/repos/philippfrenzel/yii2fullcalendar/issues/36/events","html_url":"https://github.com/philippfrenzel/yii2fullcalendar/issues/36","id":127863564,"number":36,"title":"Calendar duplicates with Pjax + browser back button","user":{"login":"cicsolutions","id":5200361,"avatar_url":"https://avatars.githubusercontent.com/u/5200361?v=3","gravatar_id":"","url":"https://api.github.com/users/cicsolutions","html_url":"https://github.com/cicsolutions","followers_url":"https://api.github.com/users/cicsolutions/followers","following_url":"https://api.github.com/users/cicsolutions/following{/other_user}","gists_url":"https://api.github.com/users/cicsolutions/gists{/gist_id}","starred_url":"https://api.github.com/users/cicsolutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cicsolutions/subscriptions","organizations_url":"https://api.github.com/users/cicsolutions/orgs","repos_url":"https://api.github.com/users/cicsolutions/repos","events_url":"https://api.github.com/users/cicsolutions/events{/privacy}","received_events_url":"https://api.github.com/users/cicsolutions/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-21T07:34:46Z","updated_at":"2016-01-21T07:34:46Z","closed_at":null,"body":"Hello,\r\n\r\nI'm using your awesome fullcalendar widget in a view using Pjax, and I was having an issue where clicking the browser back button to go back to the view with the calendar would end up triggering the widget JS again and rendering the calendar twice.\r\n\r\nI tried several ways to address the issue, and there probably are multiple ways to fix it, but in the end, what I was able to get working was I adjusted the registerPlugin method to first check if the calendar already exists before registering the javascript.\r\n\r\nSo in the `registerPlugin()` method, I made the following change:\r\n\r\n\t//$js[] = \"jQuery('#$id').fullCalendar($cleanOptions);\";\r\n\t$js[] = \"if (jQuery('#$id').children().not('.fc-loading').length == 0) { jQuery('#$id').fullCalendar($cleanOptions); }\";\r\n\r\nThis seems like a safe and helpful approach, so I thought I would share it in hopes it gets added to the core, or at least helps anyone else out that may be experiencing the same issue.\r\n"}}