Working with Bootstrap and JavaScript, and I use it as an accordion format - after clicking on a minimized div it will open and show the elements in the div based on the identifier.
Problem:
If the div does not contain the elements that I want to open, and show the message to the user:
"no items here"
How should I do it? In javascript?
This is what I have:
View
<div class="accordion-body collapse state-loading" data-group-id="13" data-bind="attr: { 'id': 'GroupMember_' + Id(), 'data-type-id': ModelId() }" id="GroupMember_15" data-type-id="15"> <div class="accordion-inner no_border" data-bind="foreach: Children"></div></div> </div>
If Children is 0 , I want it to be open and this text is shown: No items here
JavaScript:
OnSuccess: function (data) { var _groups = linq.From(options.groupData); var _groupsToUpdate = _groups .Where(function (x) { return x.Id == options.groupId; }); if (_groupsToUpdate.Any()) { _groupsToUpdate.First().Children = data.Items; }
Not sure if I am missing something else to share - let me know.
UPDATE
Layout Div:
<div class='accordion-group'> <div class='accordion-heading'> Group 1 </div> <div class='accordion-body'> <div class='accordion-inner'> <div class='element'>No items here</div> </div> </div> </div>
I need to click on the accordion class to display the accordion body and get into accordion-inner elements
source share