Title: How do we implement the bookmark click function like the one in React and Next JS Course? · Issue #8 · ByteGrad/Professional-JavaScript-Course · GitHub
Open Graph Title: How do we implement the bookmark click function like the one in React and Next JS Course? · Issue #8 · ByteGrad/Professional-JavaScript-Course
X Title: How do we implement the bookmark click function like the one in React and Next JS Course? · Issue #8 · ByteGrad/Professional-JavaScript-Course
Description: I implemented the bookmark clickhandler in rmtdev project and it works. But now I want it to work like the rmtdev project in React and Next JS course? How shoud we do that? I tried different solution and none worked like expected. This c...
Open Graph Description: I implemented the bookmark clickhandler in rmtdev project and it works. But now I want it to work like the rmtdev project in React and Next JS course? How shoud we do that? I tried different soluti...
X Description: I implemented the bookmark clickhandler in rmtdev project and it works. But now I want it to work like the rmtdev project in React and Next JS course? How shoud we do that? I tried different soluti...
Opengraph URL: https://github.com/ByteGrad/Professional-JavaScript-Course/issues/8
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How do we implement the bookmark click function like the one in React and Next JS Course?","articleBody":"I implemented the bookmark clickhandler in rmtdev project and it works. But now I want it to work like the rmtdev project in React and Next JS course? How shoud we do that? I tried different solution and none worked like expected. \r\n\r\nThis code will have problem. When we click the bookmark icon, it will show like this without the \"#\" in the url.\r\n. \r\n\r\n```\r\njobListSearchEl.addEventListener(\"click\", (event) =\u003e {\r\n if (event.target.classList.contains(\"job-item__bookmark-icon\")) {\r\n bookmarkClickHandler(event);\r\n }else{\r\n clickHandler(event)\r\n}\r\n});\r\n```\r\n\r\n\r\nThis is my bookmarkclickhandler and it works.\r\n```\r\nimport {\r\n state,\r\n bookmarksBtnEl,\r\n jobDetailsEl,\r\n jobListBookmarksEl,\r\n jobListSearchEl,\r\n} from \"../common.js\";\r\nimport renderJobList from \"./JobList.js\";\r\n\r\nconst bookmarkClickHandler = (event, bookmarkTag = \"item\") =\u003e {\r\n if (!event.target.className.includes(\"bookmark\")) {\r\n return;\r\n }\r\n\r\n if (state.bookmarkJobItems.some((jobItem) =\u003e jobItem.id === state.activeJobItem.id)) {\r\n state.bookmarkJobItems = state.bookmarkJobItems.filter((jobItem) =\u003e jobItem.id !== state.activeJobItem.id);\r\n } else {\r\n \tstate.bookmarkJobItems.push(state.activeJobItem);\r\n }\r\n\r\n\tlocalStorage.setItem(\"bookmarkJobItems\", JSON.stringify(state.bookmarkJobItems));\r\n\tdocument.querySelector(`.job-${bookmarkTag}__bookmark-icon`).classList.toggle(`job-${bookmarkTag}__bookmark-icon--bookmarked`);\r\n\trenderJobList();\r\n renderJobList(\"bookmarks\");\r\n};\r\n\r\nconst mouseEnterHandler = () =\u003e {\r\n bookmarksBtnEl.classList.add(\"bookmarks-btn--active\");\r\n jobListBookmarksEl.classList.add(\"job-list--visible\");\r\n renderJobList(\"bookmarks\");\r\n};\r\n\r\nconst mouseLeaveHandler = () =\u003e {\r\n bookmarksBtnEl.classList.remove(\"bookmarks-btn--active\");\r\n jobListBookmarksEl.classList.remove(\"job-list--visible\");\r\n};\r\n\r\nbookmarksBtnEl.addEventListener(\"mouseenter\", mouseEnterHandler);\r\njobListBookmarksEl.addEventListener(\"mouseleave\", mouseLeaveHandler);\r\njobListBookmarksEl.addEventListener(\"click\", (event) =\u003e {\r\n bookmarkClickHandler(event);\r\n});\r\njobListSearchEl.addEventListener(\"click\", (event) =\u003e {\r\n bookmarkClickHandler(event); \r\n});\r\njobDetailsEl.addEventListener(\"click\", (event) =\u003e {\r\n bookmarkClickHandler(event, \"info\");\r\n});\r\n\r\nexport default bookmarkClickHandler;\r\n```","author":{"url":"https://github.com/Rope-a-dope","@type":"Person","name":"Rope-a-dope"},"datePublished":"2024-06-05T23:11:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/8/Professional-JavaScript-Course/issues/8"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3b3bd234-0e9a-e926-8b42-eaa30b4bc332 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC7E:190031:A27310:E034CA:6A513403 |
| html-safe-nonce | 7e1486866ce64f6605f9fb682ff09d5c574bd65439c733aba0b920d997daaf53 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzdFOjE5MDAzMTpBMjczMTA6RTAzNENBOjZBNTEzNDAzIiwidmlzaXRvcl9pZCI6IjU2MzI4NDMyNDUzNDYxNzM5NTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25f774eecccb24701923a8006db972dfacafe4ce4176bcc71ef8e4fa928e3fdd |
| hovercard-subject-tag | issue:2336973043 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ByteGrad/Professional-JavaScript-Course/8/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a1e94ba9e440df0403a3e2de1889a185d9d321bc6bbbc947d6f46a12b2bcfac/ByteGrad/Professional-JavaScript-Course/issues/8 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a1e94ba9e440df0403a3e2de1889a185d9d321bc6bbbc947d6f46a12b2bcfac/ByteGrad/Professional-JavaScript-Course/issues/8 |
| og:image:alt | I implemented the bookmark clickhandler in rmtdev project and it works. But now I want it to work like the rmtdev project in React and Next JS course? How shoud we do that? I tried different soluti... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Rope-a-dope |
| hostname | github.com |
| expected-hostname | github.com |
| None | e840f405b2718e8f2d55aafa9ff27dbce17e29d0c253011d05ea0fea3c78baff |
| turbo-cache-control | no-preview |
| go-import | github.com/ByteGrad/Professional-JavaScript-Course git https://github.com/ByteGrad/Professional-JavaScript-Course.git |
| octolytics-dimension-user_id | 82057865 |
| octolytics-dimension-user_login | ByteGrad |
| octolytics-dimension-repository_id | 480343983 |
| octolytics-dimension-repository_nwo | ByteGrad/Professional-JavaScript-Course |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 480343983 |
| octolytics-dimension-repository_network_root_nwo | ByteGrad/Professional-JavaScript-Course |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ae6027e8ba70c79dc08249bb6cdc1a09d788496 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width