Skip to content

Commit 88c19f5

Browse files
committed
Fix the toggle
1 parent 4d50ac7 commit 88c19f5

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

assets/js/admin.js

+32-14
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,39 @@
332332
* Initialize group toggles
333333
*/
334334
function initGroupToggles() {
335-
// Toggle group content visibility
336-
$(document).on('click', '.stl-toggle-group', function(e) {
337-
e.preventDefault();
338-
339-
var groupId = $(this).data('group-id');
340-
var $content = $('#group-content-' + groupId);
335+
// Clean up any existing handlers
336+
$('.stl-toggle-group').off('click');
337+
338+
// Set up toggle buttons with click handler
339+
$('.stl-toggle-group').each(function() {
341340
var $button = $(this);
342-
343-
if ($content.is(':visible')) {
344-
$content.slideUp(200);
345-
$button.text(stl_admin.i18n.show_details || 'Show Details');
346-
} else {
347-
$content.slideDown(200);
348-
$button.text(stl_admin.i18n.hide_details || 'Hide Details');
349-
}
341+
var groupId = $button.data('group-id');
342+
var $content = $('#group-content-' + groupId);
343+
344+
// Make sure content starts hidden
345+
$content.hide();
346+
347+
// Set initial state
348+
$button.attr('data-state', 'closed');
349+
350+
// Add click handler
351+
$button.on('click', function(e) {
352+
e.preventDefault();
353+
e.stopPropagation();
354+
355+
// Toggle based on current state
356+
if ($button.attr('data-state') === 'closed') {
357+
$content.show();
358+
$button.text(stl_admin.i18n.hide_details || 'Hide Details');
359+
$button.attr('data-state', 'open');
360+
} else {
361+
$content.hide();
362+
$button.text(stl_admin.i18n.show_details || 'Show Details');
363+
$button.attr('data-state', 'closed');
364+
}
365+
366+
return false;
367+
});
350368
});
351369
}
352370

0 commit comments

Comments
 (0)