Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:01:36+00:00 2026-06-08T07:01:36+00:00

I’m working through a SignalR demo that displays database info in a list when

  • 0

I’m working through a SignalR demo that displays database info in a list when a button is hit.

My Hub has 2 functions: One to remove DB objects from a list, and one to re-add DB objects to that list.

These functions are performed in my View and perform great when I only have the page open once. But if I open the page in another tab (can be the same browser or a different one), the pages do not stay in sync.
Meaning, when one page’s button is hit, the other page is not displaying the data correctly.

Often times one page will do fine, while the other will perform the remove but not the add! It’s mind-boggling. They should just be reflections of each other from my understanding.

Has anyone else run into something similar?
Thanks in advance for any help!

Here’s my Hub :

[HubName("hubtest")]
public class HubTest : Hub
{
    CmsContext db = new CmsContext();

    public void showdata()
    {
        var f = from x in db.Data
                select x;
        Clients.remove();

        Clients.add(f);
    }
}

And here’s the javascript in my View for the functions:

<script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR-0.5.2.min.js" type="text/javascript"></script>
<script src="/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">

$(function () {
    var hubtest = $.connection.hubtest;

    hubtest.remove = function () {
        //clear list of any prior values
        var list = document.getElementById('dataList');
        while (list.hasChildNodes()) {
            list.removeChild(list.childNodes[0])
        }
    };

    hubtest.add = function (data) {
        //populate with updated values
        for (var i = 0; i < data.length; i++) {
            var element = data[i];
            $('#dataList').append('<li>' + element.Question + '</li>');
        }

    };

    $("#broadcast").click(function () {
        hubtest.showdata();

    });

    // Start the connection
    $.connection.hub.start();
});
</script> 


<input type="button" id="broadcast" value="broadcast" />
<ul id="dataList">
</ul>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:01:37+00:00Added an answer on June 8, 2026 at 7:01 am

    First of all thanks for your replies. I really appreciate your feedback!
    I eventually got it to where my pages are staying in sync when open in multiple tabs by altering how my data is sent to the View.
    Where I was performing the for loop in my Javascript to display each piece of data, now I am doing that in my Hub like so:

    [HubName("hubtest")]
    public class HubTest : Hub
    {
        CmsContext db = new CmsContext();
    
        public void showdata()
        {
            Clients.clearlist();
            var faqs = from x in db.Faqs
                    select x;
            foreach (Faq faq in faqs)
            {
                Clients.add(faq.Question.ToString());
            }
        }
    }
    

    Then my Javascript is just appending that FAQ question to the list:

    $(function () {
        var hubtest = $.connection.hubtest;
    
        hubtest.clearlist = function () {
            var list = $('#datalist');
            list.empty();
        };
    
        hubtest.add = function (data) {            
            $('#datalist').append('<li>' + data + '</li>');
        };
    
        $("#broadcast").click(function () {
            hubtest.showdata();
        });
    
        // Start the connection
        $.connection.hub.start();
    });
    

    Sending just a simple string of my data to be printed individually seems to allow my page to stay in sync.
    Before the data I was sending was a list of DB objects and my Javascript was looping through each and adding that object’s Question column to the list. Not sure why this was such an issue – especially since it would work on one open tab but not all open tabs – but that simple change fixed my site sync issues.
    Thanks again!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.