I used to have this table with different identifyable rows that were updated using SignalR like this:
$(document).ready(function () {
//Enable logging
$.connection.hub.logging = true;
// Proxy created on the fly
var messageHub = $.connection.messageHub;
messageHub.client.timeEnabled = true;
// ... Removed main part of the body ...
$.connection.hub.start(function () {
var table = document.getElementById("monitorList");
for (var i = 0, row; row = table.rows[i]; i++) {
var item = document.getElementById("conveyanceId-" + i).innerHTML;
messageHub.server.joinGroup(item);
}
})
Now, the structure has changed, and instead of using tables, I'm using divs, where each container has a unique id: container-@unit.UnitId
:
<div class="container">
<div class="row">
<div class="col-md-12">
@for (int i = 0; i < @Model.UnitDetails.Count; i++)
{
var unit = Model.UnitDetails[i];
<div class="panel panel-inverse sl-unit-overview" id="container-@unit.UnitId">
<div class="panel-heading">
<!-- Heading content -->
</div>
<div class="panel-body">
<!-- Body content -->
</div>
</div>
}
</div>
</div>
</div>
My question, I guess it's more like two questions: 1. How can I change my javascript to find each container like I did with the table? 2. Is my current way of doing it the correct way of doing it? (Feeling kind of uncertain)