【问题标题】:Need to implement confirmation box in grails需要在grails中实现确认框
【发布时间】:2013-05-28 15:25:15
【问题描述】:

当我按下停止按钮时,我需要在 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 中使用它时,它就无法工作

【问题讨论】:

    标签: jquery grails button popup


    【解决方案1】:

    为 yes 按钮添加一个 onclick 处理程序。

    $('.stopimg').click(function(){
        $("#stop_service").attr("onclick", "window.location.href='" + $(this).attr("href") + "';");
        loadPopupBox2();
    });
    
    $('#popupBoxClose2').click( function() {            
        $("#stop_service").removeAttr("onclick");
        unloadPopupBox2();
    });
    

    【讨论】:

    • 那句话的意义是 0。 (他删除了评论)
    • 好的, 停止  ,这就是导致问题的原因。如果我使用 而不是这个,弹出窗口会出现。
    • onclick="return false;" 添加到您的锚标签
    猜你喜欢
    • 1970-01-01
    • 2015-03-16
    • 1970-01-01
    • 1970-01-01
    • 2010-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多