Why javascript code not work inside blade file?

No description
9 Replies
BKF Dev
BKF Dev7mo ago
where's the commentReply input ?
LeandroFerreira
LeandroFerreira7mo ago
what are you trying to do?
Alnuaimi
AlnuaimiOP7mo ago
in the same file mention user in comment
Alnuaimi
AlnuaimiOP7mo ago
No description
LeandroFerreira
LeandroFerreira7mo ago
and what JS isn't working?
toeknee
toeknee7mo ago
You are likely calling it post dom? So it won't re-activate
Alnuaimi
AlnuaimiOP7mo ago
Sure! Here are the steps to integrate Mentions.js into your comment system using FilamentPHP and Livewire: Step 1: Include Mentions.js Library Add the following links to the head of your template to include the Mentions.js library: html Copy code <link rel="stylesheet" href="https://unpkg.com/mentions.js/dist/mentions.css"> <script src="https://unpkg.com/mentions.js/dist/mentions.min.js"></script> Step 2: Setup the Script Add the following script at the bottom of your Blade template. This script sets up the Mentions.js library to work when the page loads: blade Copy code @script <script> document.addEventListener('DOMContentLoaded', function () { alert("sds"); new Mentions({ query: async function(text, callback) { try { let response = await fetch(/api/users?search=${text}); let users = await response.json(); callback(users.map(user => ({ id: user.id, value: user.name, avatar: user.avatar, // If you have user avatars }))); } catch (error) { console.error('Error fetching users:', error); callback([]); } }, selector: '.mentionable', trigger: '@', minChars: 1, debounceTime: 100, suggestionsHighlight: true }); }); </script> @endscript __ see chat Gpt
No description
BKF Dev
BKF Dev7mo ago
Try to remove push(script) tag

Did you find this page helpful?