在jquery确认之后jquery弹出窗口

时间:2010-08-02 08:37:34

标签: javascript jquery jquery-ui

点击jsp中的“删除”链接后,我有一个确认框。现在问题是成功删除页面显示在同一个窗口中。

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

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

<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>

感谢名单

2 个答案:

答案 0 :(得分:0)

当您点击删除时,会显示确认框,然后提交表单。

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

我用jconfirm做了一次:

<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并隐藏它:

<div style="display:hidden" id="loadhtml">
</div>

答案 1 :(得分:0)

如果您需要最高级版本的 - jconfirmaction.jquery.js,请与您分享。