Guest User

final

a guest
Apr 11th, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function loadUserMessage(senderId) {
  2. $.ajax({
  3. url: "/chat/getuser/" + senderId,
  4. type: "GET",
  5. dataType: "html",
  6. success: function (data) {
  7. // Clean up any extra quotes
  8. data = data.replace(/^”|”$/g, '');
  9.  
  10. const $newContent = $(data);
  11.  
  12. // Remove 'chat-active' class from existing if needed
  13. $('#people-box .chat-active').removeClass('chat-active');
  14.  
  15. // Append new HTML
  16. $('#people-box').append($newContent);
  17.  
  18. // Reinitialize plugins/events for the new elements
  19. initializeChatComponents($newContent);
  20. },
  21. error: function (xhr, status, error) {
  22. console.error("Error retrieving messages: " + error);
  23. }
  24. });
  25. }
  26.  
  27. function initializeChatComponents($context) {
  28. // Example reinitializations
  29. $context.find('.tooltip').tooltip(); // Bootstrap
  30. $context.find('.custom-scroll').customScrollbar(); // Your plugin
  31. $context.find('.chat-item').on('click', function () {
  32. // Your chat item click logic
  33. });
  34. }
Advertisement
Add Comment
Please, Sign In to add comment