Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadUserMessage(senderId) {
- $.ajax({
- url: "/chat/getuser/" + senderId,
- type: "GET",
- dataType: "html",
- success: function (data) {
- // Clean up any extra quotes
- data = data.replace(/^”|”$/g, '');
- const $newContent = $(data);
- // Remove 'chat-active' class from existing if needed
- $('#people-box .chat-active').removeClass('chat-active');
- // Append new HTML
- $('#people-box').append($newContent);
- // Reinitialize plugins/events for the new elements
- initializeChatComponents($newContent);
- },
- error: function (xhr, status, error) {
- console.error("Error retrieving messages: " + error);
- }
- });
- }
- function initializeChatComponents($context) {
- // Example reinitializations
- $context.find('.tooltip').tooltip(); // Bootstrap
- $context.find('.custom-scroll').customScrollbar(); // Your plugin
- $context.find('.chat-item').on('click', function () {
- // Your chat item click logic
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment