首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquery确认后弹出jquery

问jquery确认后弹出jquery
EN

Stack Overflow用户
提问于 2010-08-02 16:37:34
回答 2查看 838关注 0票数 1

单击jsp中的"Delete“链接后,我会看到一个确认框。现在的问题是成功删除页面显示在同一个窗口中。

我想在弹出窗口中显示它。

我尝试使用javascript onclick(),但它不工作。那么,我该怎么做呢?

代码语言:javascript
复制
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jconfirmaction.jquery.js"></script>


<script type="text/javascript">

            $(document).ready(function() {


                $('.ask-plain').click(function(e) {

                    e.preventDefault();
                    thisHref    = $(this).attr('href');

                    if(confirm('Delete this record?')) {
                        window.location = thisHref;
                    }

                });

                $('.ask-custom').jConfirmAction({question : "Anda Yakin?", yesAnswer : "Ya", cancelAnswer : "Tidak"});
                $('.ask').jConfirmAction();
            });

        </script>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />


<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=750,height=430,scrollbars=no');
return false;
}
//-->
</SCRIPT>

---Delete image
<td  width="3%" align="left"><a href="cir_delete.jsp?cir_id=<%=rs.getString("cir_id")%>" class="ask"><IMG SRC="12.png" ALT="Delete" BORDER="0"></a></td>

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-08-02 16:44:48

单击delete时,将显示确认框,然后表单将被提交。

您需要做的是通过jquery提交表单,显示结果并将其传递到弹出框中。我很快就会给出一个例子。

我曾经用jconfirm这样做过一次:

代码语言:javascript
复制
<script type="text/javascript">
        $(document).ready(function(){
            // give all your delete links a class="del" then when this is clicked, execute following:
            $(".del").click(function () {
            //get the href from th link you clicked
            var href = $(this).attr("href");
                activate JConfirm
                jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
                  // if confirm is clicked: 
                  if(r){
                       //post the form serialised to the url
                       $.post(href, $("#yourtestform").serialize(),
                          function(data){
                            // the posted form will return html data, load this data in a hidden div
                            $('#loadhtml').html = data;
                            // now that the data is loaded, open a colorbox with the hidden div as content (don't forget to include the colorbox.js
                            $('#loadhtml').colorbox();
                          };
                       );
                   }
                   //if the person clicked cancel: do nothing
                   else{
                        return false;
                   }
                });
                // insure that the form doesn't post itself again after jquery is finished
                return false;
            });
        });
    </script>

我假设你想使用像colorbox这样的模式弹出窗口,或者在底部定义一个div,在那里你可以在帖子之后加载html并隐藏它:

代码语言:javascript
复制
<div style="display:hidden" id="loadhtml">
</div>
票数 0
EN

Stack Overflow用户

发布于 2015-03-14 14:40:01

如果你需要最高级版本的- jconfirmaction.jquery.js,会分享给你的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3386213

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档