9 Replies
where's the commentReply input ?
what are you trying to do?
in the same file
mention user in comment
and what JS isn't working?
You are likely calling it post dom? So it won't re-activate
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 Gptmaybe this approach can help you
https://discord.com/channels/883083792112300104/1257957993753083914/1258053353167126549
Try to remove push(script) tag