单击模态提交按钮后打开警报窗口

时间:2017-11-20 22:30:06

标签: javascript jquery html twitter-bootstrap modal-dialog

<div class="modal" id="myInquiry" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">&times;</button>
                <h4 id="myModalLabel">Thank you for your feedback:</h4>
            </div>
            <div class="modal-body">
                <label for="inquiry">Feedback:</label>
                <textarea class="form-control" rows="5" id="inquiry"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary" data-dismiss="modal" id="send">Send</button>
            </div>
        </div>
    </div>
</div>

这是我的模态页脚的代码。我想点击发送按钮并关闭模态。一旦关闭,我想要一个警告窗口或模式弹出,并感谢用户提供反馈。我是网络开发的新手,经过多次尝试后(在找到其他问题的不同解决方案后)我就陷入了这个问题,但没有任何工作。

如果有帮助,模态的div id是'myInquiry'。

谢谢!

4 个答案:

答案 0 :(得分:1)

你需要在你的模态关闭按钮上添加一个动作,最糟糕的方式是:

 <button type="button" class="btn btn-default" data-dismiss="modal" onclick="alert('thank you');">Close</button>

您可以将ID添加到按钮,然后使用jQuery来处理操作,并显示比这更好的内容。

答案 1 :(得分:1)

您可以像这样添加jQuery代码。

$('button#send').click(function() {
   alert('Alert Content');
}

然后你可以看到警报&#34;警报内容&#34;单击“发送提交”按钮时。

答案 2 :(得分:0)

Bootstrap模式有一个set.seed(123) df <- data.frame(gr=rep(seq(1,2),each=10),sub_gr=rep(rep(c("a","b"),each=5),2), y = rep(c(sort(runif(5,0,0.5),decreasing=TRUE), sort(runif(5,0,0.5),,decreasing=TRUE)),2), x = rep(c(seq(0.1,0.5,0.1),rev(seq(-0.5,-0.1,0.1))),2)) df %>% group_by(gr, sub_gr) %>% filter((sub_gr %in% "a" & row_number() %in% 1:3) | (sub_gr %in% "b" & row_number() %in% (n() - 1):n())) %>% ungroup() # # A tibble: 10 x 4 # gr sub_gr y x # <int> <fctr> <dbl> <dbl> # 1 1 a 0.47023364 0.1 # 2 1 a 0.44150870 0.2 # 3 1 a 0.39415257 0.3 # 4 1 b 0.22830737 -0.4 # 5 1 b 0.02277825 -0.5 # 6 2 a 0.47023364 0.1 # 7 2 a 0.44150870 0.2 # 8 2 a 0.39415257 0.3 # 9 2 b 0.22830737 -0.4 # 10 2 b 0.02277825 -0.5 事件,你可以听到那个事件,然后,当模态关闭(对用户隐藏)时,你可以显示感谢模态。以下是CSSC的示例。干杯,sigfried。

答案 3 :(得分:0)

也许你可以尝试添加

onclick="window.alert('<Your text here>')"

属性为按钮。