开发者

Popup message window in grails?

I have a Grails application with a form in it. Once the user has entered the data and submitted it, and it's been validated etc.. I need a message to开发者_StackOverflow popup in a little window to give the user some feedback - it needs to popup, rather than be displayed on the page. Can anyone advise me on the best way to do this?


I have implemented the same mechanism for my application, and I am using the jQuery plugin 'smartmodal' (used by the Nimble plugin originally). See here

You simply have to redirect the request in the controller validation code to a GSP page containing the following code:

<script type="text/javascript" src="${resource(file: 'jquery-1.3.2.js')}"></script>
<script type="text/javascript" src="${resource(file:'jquery.smartmodal.js')}"></script>
<LINK rel="stylesheet" href="./css/smartmodal.css">
...
<body>
...
<g:javascript>
$(function() { 
 $("#msg").hide();
 $("#msg").modal({hide_on_overlay_click:false});
 $("#msg").modal_show();});
</g:javascript>
<div id="msg">
My feedback message is here 
</div>
<g:link controller="..." action="...">Close</g:link>

I hope it helps,

Fabien

EDIT: An extract of the smartmodal.css file that will render the 'modal effect' is:

#modal_content {
    display: none;
    position: fixed;
    left: 50%;
    padding: 0px;
    top: 10%;

    background: #FFF;
    border: 0px solid #d2d2d2;

    width: 400px;
    margin-left: -200px;
    text-align: left;
}

#modal_overlay {
    background-color: #000;
}

However if you want the complete file, it is available inside the great Nimble grails plugin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜