当我按下停止按钮时,我需要在grails中实现一个确认消息框。我的停止按钮的代码是
<a class="stopimg" href="${createLink(controller: 'Test', action: 'Stop', id: i.Id)}"> Stop </a>
我也创建了确认信息框。
<div id="popup_box2">
<div class="popup-warapper">
<form name="">
<div class="popup-title"><a id="popupBoxClose2" class="popup-close"><img alt="close" src="images/close.png"></a>
<div class="title">Confirmation</div>
<div class="clear"></div>
</div>
<div class="popup-content">
<div>Are you sure you want to Stop the server?</div>
</div>
<div class="buttons"> <span>
<input class="popupBtn" type="button" value="Yes" name="stop_service" id="stop_service" />
<input class="popupBtn" type="button" value="No" name="none" id="none" />
</span> </div>
</form>
</div>
</div>
我正在加载这个
$('.stopimg').click(function(){
// When site loaded, load the Popupbox First
loadPopupBox2();
});
$('#popupBoxClose2').click( function() {
unloadPopupBox2();
});
function loadPopupBox2() { // To Load the Popupbox
$('#popup_box2').fadeIn("slow");
$('#popup_box2').css({ "left":(screen.width/2)-(285/2)});
$("#mainWrapper").css({ // this is just for style
"opacity": "0.3"
});
}
function unloadPopupBox2() { // TO Unload the Popupbox
$('#popup_box2').fadeOut("slow");
$("#mainWrapper").css({ // this is just for style
"opacity": "1"
});
}
我需要以某种方式将其链接到我的停止按钮。如果我使用html按钮代码正在工作,但当我在grails中使用它时它无法正常工作
答案 0 :(得分:0)
将一个onclick处理程序添加到yes按钮。
$('.stopimg').click(function(){
$("#stop_service").attr("onclick", "window.location.href='" + $(this).attr("href") + "';");
loadPopupBox2();
});
$('#popupBoxClose2').click( function() {
$("#stop_service").removeAttr("onclick");
unloadPopupBox2();
});