I am attempting to create collapsible panels with a resize button by incorporating the following JavaScript code:
function toggleSize() {
$(".elementGraphic").click(function () {
$(this).toggleClass("col-md-12");
$(this).toggleClass("col-md-6");
});
};
The corresponding HTML code looks like this:
<div class="col-md-12 ui-state-default elementGraphic">
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading ">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse1" class="component-button max-min-button more-less glyphicon glyphicon-chevron-up"></a>
<a href="#" class="component-button resize-button glyphicon glyphicon-resize-small" onclick="toggleSize.call(this)"></a>
Graphic 1
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in element"><canvas class="chart" id="myChart"></canvas></div>
</div>
</div>
</div>
Unfortunately, I am facing issues with this code. There are times when multiple clicks are required for resizing and sometimes the chart inside does not resize along with the div element. I aim to find a solution that works uniformly across all elements using classes instead of IDs.
If needed, I can explore integrating AngularJS as well.
Your assistance is greatly appreciated.