Question

I am using a jquery ui to display messages, but it is not opening automatically if message is not empty.

<script>
    $(function() {
        $( "#dialog-message" ).dialog({
            autoOpen: false,
            modal: true,
            buttons: {
                Ok: function() {
                $( this ).dialog( "close" );
                }
            }
     });
</script>

<c:choose>
    <c:when test="${not empty message}">
        <div id="dialog-message" title="Server Message">
            <p>'${message}'</p>
        </div>

        <script>
           $( "#dialog-message" ).dialog( "open" );
        </script>
        </c:when>
        <c:otherwise>
        </c:otherwise>
</c:choose>

Just to test if it is working i tried putting a button to open the modal box manually on click and it is working.

And also it will work if I remove autoOpen: false.

thanks

Was it helpful?

Solution

You have to set autoOpen to true. Demo :http://jsfiddle.net/GCu2D/82/

$(document).ready(function () {
var dialog = $('selector').dialog({
    autoOpen: true,
    buttons: {
        "Yes": function () {
            alert('you chose yes');
        },
            "No": function () {
            alert('you chose no');
        },
            "Cancel": function () {
            dialog.dialog('close');
        }
    }
});
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top