2010-01-09 59 views
0

我有一個格式的Grails應用程序。一旦用戶輸入了數據並提交了數據,並且已經被驗證等等。我需要一個消息在一個小窗口中彈出來給用戶一些反饋 - 它需要彈出,而不是顯示在頁面上。任何人都可以建議我最好的方法來做到這一點?Grails中的彈出消息窗口?

回答

3

我爲我的應用程序實現了相同的機制,並使用jmod插件'smartmodal'(最初由Nimble插件使用)。見here

您只需重定向在控制器驗證代碼包含以下代碼GSP頁面的請求:

<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> 

我希望它能幫助,

法比安斯基

編輯smartmodal.css文件中提取'模態效果'的提取文件是:

#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; 
} 

但是如果你想要完整的文件,它可裏面的大Nimble Grails的插件

+0

您好,感謝這個 - 我掙扎了一下它雖然,當它重定向它打開這在主窗口而不是一個小窗口。任何想法,我哪裏錯了? – ellander 2010-01-10 21:41:16

+0

如果出現主窗口而不是模態窗口,則意味着未調用'modal_show()'函數或未包含CSS文件smartmodal.css。我會檢查JS和CSS文件都包含在你的html頁面中。我已經更新了包含CSS文件 – fabien7474 2010-01-10 22:51:28

+0

好的代碼,我只能從你建議的鏈接中找到zip中的modal.css,但這似乎並不奏效 - smartmodal.css與modal.css不同一?非常感謝您的幫助 – ellander 2010-01-10 23:32:39