How to detect the bootbox status

Hi,

i’m trying to detect if a modal (“bootbox” on Xibo) is visible or not.

The reason is that i have a javascript loop in the modal, and when a user closes it this timeout() loop must close, otherwise it continues to work with the modal closed.

This is the code:

{#
/*
 * Spring Signage Ltd - http://www.springsignage.com
 * Copyright (C) 2015 Spring Signage Ltd
 * (${FILE_NAME})
 */

#}

{% extends "form-base.twig" %}

{% block formTitle %}
    {% trans "My Modal " %}{{ modal.name }}
{% endblock %}

{% block formButtons %}
    {% trans "Close" %}, XiboDialogClose()
{% endblock %}

{% block formHtml %}
    <div class="row">
        <div class="col-md-12">
            <script>
                refresh();
                // Checks if layout is changed and update form
                function refresh() {
                    setTimeout(function () {
                        $.post( '{{ urlFor("displayGroup.action.command.refresh", {"id": displayId}) }}',
                        function( data ) {
                            
							( ... )
							
                        });
                        if($('#bootbox').css('display') == 'block')
                        {
                            refresh();
                        }
                    }, 4000);
                }
            </script>
        </div>
    </div>
{% endblock %}

I’m trying to detect through JQuery if ‘bootbox’ display css == block but this does not work.
What do you suggest?

Thanks

Any suggestions…? :rolling_eyes:

Solved in this way:

if ($('.bootbox').css('display') != 'block') {
                                clearInterval(myVar);
                            }
1 Like

Sorry - i’ve been rushed off my feet! Glad you have solved it.