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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:25:42+00:00 2026-06-12T07:25:42+00:00

I’m working on a project that is using knockout.js and jQuery Mobile. I have

  • 0

I’m working on a project that is using knockout.js and jQuery Mobile. I have an observable array of observable properties. This observable array is getting populated with JSON data via an AJAX call to the server (Web API).

// ViewModel
my.vm = function () {
    var
    alarms = ko.observableArray([]),
    loadAlarmsCallback = function (json) {
        $.each(json.Alarms, function (i, p) {
            alarms.push(new my.Alarm()
                .AlarmID(p.AlarmID)
                .StartTime(my.utilities.formatDate(p.StartTime))
                .EndTime(my.utilities.formatDate(p.EndTime))
                .TimeAcknowledged(my.utilities.formatDate(p.TimeAcknowledged))
                .AcknowledgedBy(p.AcknowledgedBy)
                .AlarmType(p.AlarmType)
                .AlarmCategory(p.AlarmCategory)
                .AlarmPriority(p.AlarmPriority)
                .Message(p.Message));
        }),
    loadAlarms = function () {
        my.dataService.getAllAlarms(my.vm.loadAlarmsCallback);
    },
    ...;
    return {
        alarms: alarms,
        loadAlarmsCallback: loadAlarmsCallback,
        loadAlarms: loadAlarms,
        ...
    };
}();

my.vm.loadAlarms();
ko.applyBindings(my.vm);

As you can see, each row in the array in the viewmodel has a StartTime, which is actually a date and time that is getting formatted to MM/dd/yyyy HH:mm.

In my view (a jQuery Mobile enabled .cshtml file), I have a foreach binding for the array on ul/li tags.

<ul data-bind="foreach: alarms" data-role="listview" data-inset="true" data-theme="c">
    <!-- NEED ONLY ONE list-divider PER DAY -->
    <li data-role="list-divider"><span data-bind="text: StartTime"></span></li>
    <!-- NEED MULTIPLE li TAGS FOR EACH ALARM ON THAT DAY -->
    <li>
        <p><span data-bind="text: AlarmCategory"></span></p>
        ...
    </li>
</ul>

What I need is only one list-divider row per day to be displayed with all the individual alarm rows on that day to be grouped under that list-divider row. When the day changes (based on the StartTime value in the viewmodel’s observable array), a new list-divider row is created and displayed with that day’s alarms underneath it.

Anyway, how can I code this scenario? Any ideas?

Thanks.

  • 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-12T07:25:43+00:00Added an answer on June 12, 2026 at 7:25 am

    One way to do it is making a computed observable alertsPerDay which builds an array where each element corresponds to one day. The element’s value is an object containing the date (because you want to show it in the view) and a nested array of alarms which belong to that day. Then in the HTML you can have a nested foreach for each day’s alarms. It’s not trivial to build but it’s not too complex either.

    Here’s a simple example of how to do that: http://jsfiddle.net/antishok/KXhem/49/

    The main idea is that you can represent your data in the way that’s most suitable for your views, and then the KO bindings themselves are trivial.

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

Sidebar

Related Questions

I'm working on a project that is using jQuery, which I'm much more familiar
I'm working on a solution where I have a WPF project that is using
I am currently working on a project that is using Dojo as the js
I'm working on a project that is currently using the Zend Framework 1.7.6, however
I'm working on a project that is considering using Cassandra as a database. We
I am working on a Spring Web Project that we are using Subversion, Eclipse
I am working on a Silverlight project that uses Django on the server using
I using Django tagging project. That is was very stable project. Working on django
I have a working project that Im amending, it crashes after trying to use
I'm working on a project that is using code from an OpenSource project. One

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.