23.03.2020, 15:29
There's an easier way to show a widget by simulating a click on the element that opens it. Make sure that your sending script is not attached to the same element otherwise you will get a loop.
Here, when 1/1/1 value is true view is switched to plan 12 and if #widget-2 is not yet shown a click event is triggered on an element with class show-widget
Here, when 1/1/1 value is true view is switched to plan 12 and if #widget-2 is not yet shown a click event is triggered on an element with class show-widget
Code:
$(function() {
if (typeof grp == 'object') {
grp.listen('1/1/1', function(obj, state) {
if (state == 'value' && obj.value) {
showPlan(12);
if (!$('#widget-2').is(':visible')) {
$('.show-widget').click();
}
}
});
}
});