1

当我按下停止按钮时,我需要在 grails 中实现一个确认消息框。我的停止按钮的代码是

<a class="stopimg" href="${createLink(controller: 'Test', action: 'Stop', id: i.Id)}">&nbsp;Stop&nbsp;</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 中使用它时,它无法正常工作

4

1 回答 1

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();
});
于 2013-05-28T15:37:10.230 回答