Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I have a function in javascript which adds a li element to an unordered list - connection is a signalR client connection, and messagelist a var pointing to a ul

connection.on("PGNotify", function (message)
    var li = document.createElement('li');
    console.log("Notification received --> " + message);
    li.textContent = message;

The new item appears on the page very briefly and then dissappears - any ideas ?

What I have tried:

Google seems to suggest there is a submit button on the page somewhere which causes a reload of the page
Updated 10-Feb-23 9:58am
Richard Deeming 11-Apr-23 5:12am    
I'd start by setting a DOM subtree modification breakpoint on the message list element, to see if that gives you any clues:
Pause your code with breakpoints - Chrome Developers[^]
pkfox 11-Apr-23 7:32am    
I think the problem is, the page is refreshed after the script runs so the DOM is being overwritten
Richard Deeming 11-Apr-23 7:50am    
In that case, go to the dev tools console and execute:

That should break into the debugger when the page reloads, and let you inspect the call-stack to see what caused it.

The other possibility would be if something is replacing the message list element, or one of its ancestors. In that case, a "subtree modified" breakpoint on the body would probably be your best bet.
pkfox 11-Apr-23 8:15am    
Thanks Richard as you know all this Web stuff makes me glaze over :-) I need to find a way of capturing the notification outside of a form

1 solution

I see that this is a "notification message" which means it should probably hide itself after a specified interval.

There could be:
1. a JavaScript (client side) setTimeout() method which fires and removes the element
2. (more difficult to find) signalR method (running from server side) which hides or removes the element.

It would be difficult to determine without seeing all of the code.
Share this answer
pkfox 11-Feb-23 3:50am    
Hi and thanks for your thoughts, there are no setTimeout() calls and certainly no SignalR method - this is a hobby project and pretty basic

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900