{"action":"opened","issue":{"url":"https://api.github.com/repos/Szalkowski/webapp/issues/8","repository_url":"https://api.github.com/repos/Szalkowski/webapp","labels_url":"https://api.github.com/repos/Szalkowski/webapp/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/Szalkowski/webapp/issues/8/comments","events_url":"https://api.github.com/repos/Szalkowski/webapp/issues/8/events","html_url":"https://github.com/Szalkowski/webapp/issues/8","id":148189161,"number":8,"title":"Przypisanie menu do zmiennej","user":{"login":"klojniewski","id":1418746,"avatar_url":"https://avatars.githubusercontent.com/u/1418746?v=3","gravatar_id":"","url":"https://api.github.com/users/klojniewski","html_url":"https://github.com/klojniewski","followers_url":"https://api.github.com/users/klojniewski/followers","following_url":"https://api.github.com/users/klojniewski/following{/other_user}","gists_url":"https://api.github.com/users/klojniewski/gists{/gist_id}","starred_url":"https://api.github.com/users/klojniewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klojniewski/subscriptions","organizations_url":"https://api.github.com/users/klojniewski/orgs","repos_url":"https://api.github.com/users/klojniewski/repos","events_url":"https://api.github.com/users/klojniewski/events{/privacy}","received_events_url":"https://api.github.com/users/klojniewski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-13T21:34:14Z","updated_at":"2016-04-13T21:34:14Z","closed_at":null,"body":"```\r\n$('.hamburger').on('click', function(event){\r\n        event.stopPropagation();\r\n        $('.menu').toggle();\r\n    });\r\n    $('.menu').on('click', function(){\r\n        $('.menu').hide();\r\n   });\r\n```\r\n\r\nW powyższym kodzie 3x odwołujesz się do menu.\r\nMożesz zastosować tzw. Cache czyli:\r\n\r\n```\r\nvar $menu = $('.menu');\r\n$('.hamburger').on('click', function(event){\r\n        event.stopPropagation();\r\n        $menu.toggle();\r\n    });\r\n    $menu.on('click', function(){\r\n        $menu.hide();\r\n   });\r\n```\r\n\r\nDzięki temu:\r\n\r\n- jQuery raz pobierze ten element w momencie definiowania zmiennej a nie za każdym razem jak wcześniej (3 razy),\r\n- masz lepszy kod"}}