I've got the following div hierarchy in my page!
<div id="bill-list">
<div id="bill-panel">
<!-- Bill -->
<div class="bill">
<!-- Bill description - Holds Bill details -->
<div class="bill-description">
<div class="bill-info bill-number"><span>000A</span></div>
<div class="bill-info table-name"><span>TABLE 78</span></div>
<div class="bill-info room-number"><span>A678</span></div>
<div class="bill-info amount"><span>76.00 USD</span></div>
<div class="bill-remove-icon"></div>
</div>
<!-- Bill Item list -->
<div class="bill-item-list">
<!-- Item : This is a sample element & will be cleared when system loads -->
<div class="bill-item">
<!-- Item image -->
<div class="bill-item-img"></div>
<!-- Item description -->
<div class="bill-item-description">
<div class="bill-item-name">
<!-- Item Name -->
<p class="bill-item-name-left">Normal Cofee</p>
<!-- Item Price -->
<p class="bill-item-name-right">170.00</p>
<div class="clear"></div>
</div>
<!-- Total item price -->
<div class="bill-item-price">
<span>170.00 USD</span>
</div>
<!-- Item Quantity -->
<div class="bill-item-amount">
<span>1</span>
</div>
</div>
<!-- Increas & Decrease item Quantity -->
<div class="bill-amount-selection">
<a class="amount-increase" href="#"></a>
<a class="amount-decrease" href="#"></a>
</div>
</div>
<!-- Remove bill link -->
<div class="item-drop-point"></div>
</div>
</div>
</div>
</div>
I'm designing a web application where I load the bills and create each bill using jQuery. So I create each element of bill and append them to the bill panel! I've enabled scrolling of the bill list using the following code. I've used dragscroller as the scrolling plugin.
$('#bill-list').dragscrollable({dragSelector: '#bill-panel', acceptPropagatedEvent: true});
And the bill has a click event of it's own where I expand the bill using jQuery slide toggle.
$(document).on('click',".bill-description",function()
{
//close all bills
$(".bill-item-list").not($(this).next(".bill-item-list")).slideUp(600);
//open the clicked bills
$(this).next(".bill-item-list").slideToggle(600);
});
The above code closes any other element that is open and expand the clicked bill. Following is the CSS used for the elements.
#bill-list {
max-height: 581px;
overflow: hidden;
}
#bill-panel {
max-height: 575px;
}
.bill {
width: 100%;
margin-top: 2px;
}
.bill-description {
height: 30px;
font-family: MyriadProReg;
background-color: rgb(214, 214, 214);
cursor: pointer;
}
All these effects work fine. The problem is when I expand an element that is in the bottom of the bill panel, it gets expanded, but I have to manually scroll to view the expanded section. I've go no idea on how to fix it!
What I need is a help to do the following. There is a list of bills that can be scrolled. Each bill has around 5 bill items. and when I expand an element at the bottom of the bill panel, bills should auto scroll to show the expanded bill.
