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 8496229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:47:40+00:00 2026-06-10T23:47:40+00:00

I have some content that loads from Jade when page loads (for example, a

  • 0

I have some content that loads from Jade when page loads (for example, a connected users list). This content is dynamic and client is notified of its changes via socket.io messages. A jQuery script in client-side must add the new content or remove the old one.

The problem is that the new content can be very complex (for example, all the information of users) and I’ve to rewrite the HTML code in the client-side script (and jQuery is not intended for that).

I’ve tried to clone and edit an existing structure (can be hidden) but I think it’s no the best way.

Example

Server-side

#usersList
    each user in users
        .userBox
            .userName #{user.name}
            .userCountry #{user.country}
            .userMail #{user.mail}

Client-side

websocket.on('newUser', function(user) {
    $('<div class="userBox">'+
        '<div class="userName">' + user.name +'</div>'+
        '<div class="userCountry">' + user.country +'</div>'+
        '<div class="userMail">' + user.mail +'</div>'+
    '</div>').appendTo($('#usersList'));
});

Client-side code is horrible. I wonder if I could have a block of content in Jade and do this.

websocket.on('newUser', function(user) {
    $(jade.userBox(user)).apprendTo('#usersList');
});

If it’s not possible, what is the best way?

  • 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-10T23:47:41+00:00Added an answer on June 10, 2026 at 11:47 pm

    I would not use jade to render the users because I would have 2 ways to insert users, one for when loading the page and a another for when updating. That was going to be too complex to handle with the class that handles users. So I just use jade to create the page template (placeholders) and get data to client side.

    var local_data ={}
    local_data.users =!{JSON.stringify(usersList)}
    div#users(class="ui-bar ui-bar-h")
    

    js:

    users.add(data);
    

    Where users.add() will actually store userdata and options in an array and do some DOM manip with jquery

    This can used when loading and when updating seamlessly

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

Sidebar

Related Questions

I have a page that loads content through AJAX. Among this content are some
I have a page, with a navigationbar that loads content, from another page, into
Hey guys I simply cannot get this to work. I have some content that
I have some HTML that looks like this: <div class=product> Content In Here <div
I have an action 'approval' that renders a view which displays some content from
I have a document that loads some content into a div with JQuery's .load()
I have created a page that loads data from a query string. And creates
I have a MVC application that reads some data from a database and loads
I have a site that get content from other sites with some JSON and
I have some javascript code that loads images dynamically in a web page: imageSrc

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.