How to Open collapsed div
var ProcessViewContent = '';
if (json != '') {
$.each(json, function (index, obj) {
ProcessViewContent += '
';
ProcessViewContent += '
ProcessViewContent += '
';
ProcessViewContent += '
ProcessViewContent += '
';
ProcessViewContent += '
ProcessViewContent += '
';
ProcessViewContent += '
ProcessViewContent += '
';
using this code
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mukesh NailwalPosted Apr 9, 2024, 7:10 AM
Using JavaScript, you can use an event listener to toggle a CSS class that manages the div's display property, opening a collapsed div. Here's how to change your code to make this happen:
var ProcessViewContent = '';
if (json != '') {
$.each(json, function (index, obj) {
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += ''; // Add a button to toggle collapse
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
ProcessViewContent += '
});
}
// Function to toggle collapse
function toggleCollapse(id) {
var element = document.getElementById(id);
if (element.classList.contains('collapsed')) {
element.classList.remove('collapsed');
} else {
element.classList.add('collapsed');
}
}
The button that I've added to each collapsed div in this modification has a onclick event that calls the toggleCollapse function and passes the TaskID as an argument. Toggle the collapsed class of the div with the supplied id using the toggleCollapse method.
Now, each collapsed div's "Toggle" button allows you to choose how visible it is. To modify how the div looks when collapsed, modify the collapsed class in your CSS.
Jayraj ChhayaPosted Apr 9, 2024, 6:05 AM
By attaching a click event to the collapsed div, you can dynamically open it when the user interacts with it.