English 中文(简体)
Boot Box Confirm Dialog problems
原标题:Bootbox Confirm Dialog problems

Unfortunately, the doc Bootbox ( http://paynedigital.com/2011/11/bootbox-js-alert-confirm-dialogs-for-twitter-bootstrap ) not teach how to call the confirm dialog. As it is in the doc window always appears when the page is loaded, what is wrong, should appear when called by clicking on a delete button. This is the code that tried unsuccessfully.

// show "false" does not work, the confirm window is showing when page is loaded.
$(function () {
bootbox.confirm("Confirm delete?", "No", "Yes", function(result) {
show: false
});     
});

// need show the confirm window when the user click in a button, how to call the confirm window?

<td><a class="icon-trash" onclick="bootbox.confirm();" href="{% url  del_setor  setor.id %}" title="Delete"></a></td>

How do I set this bootbox to appear only when the delete button is clicked? Thanks!

缩略语:

$(function () {
$("a#confirm").click(function(e) {
    e.preventDefault();
    var location = $(this).attr( href );
    bootbox.confirm("Confirm exclusion?", "No", "Yes", function(confirmed) {
        if(confirmed) {
        window.location.replace(location);
        }
    });
});     
});

Now, the deletion works when i click in "yes". I asked the developers of the plugin to put the full sample in the doc, so users do not need to create posts about how to remove the object when "yes" is clicked. Regards.

最佳回答

您不妨在本页“基本用法”下的“企业”链接上核对来源:http://uchjs.com/

这里指:

$("a.confirm").click(function(e) {
    e.preventDefault();
    bootbox.confirm("Are you sure?", function(confirmed) {
        console.log("Confirmed: "+confirmed);
    });
});

假定贵格会可在你重新工作的德国马克,我就避免在座标上使用<条码>。 仅谈两点。

问题回答

我也需要这样做,但我改变了几条东西...... 看......

Add this function into your global "jQuery Ready" function like that:

$(document).on("click", "[data-toggle="confirm"]", function (e) {
    e.preventDefault();
    var lHref = $(this).attr( href );
    var lText = this.attributes.getNamedItem("data-title") ? this.attributes.getNamedItem("data-title").value : "Are you sure?"; // If data-title is not set use default text
    bootbox.confirm(lText, function (confirmed) {
        if (confirmed) {
            //window.location.replace(lHref); // similar behavior as an HTTP redirect (DOESN T increment browser history)
            window.location.href = lHref; // similar behavior as clicking on a link (Increments browser history)
        }
    });
});

仅添加一些“数据-*属性”给你的子孙,或与下列内容相连接:

<a class="btn btn-xs btn-default" data-toggle="confirm" data-title="Do you really want to delete the record 123?" href="/Controller/Delete/123"><span class="fa fa-remove"></span> </a>

因此 这样,你就可以有一个个个性化的问题。 这对你们的使用者来说更具有启发性。

你们是否喜欢?

See demo: jsfiddle

$(document).on("click", ".confirm-modal", function(e) {
    e.preventDefault();
    bootbox.confirm("Are You sure?", function(result) {
        if(result) {
            top.location.href = e.target.href;
        }
    });
});

<asp:LinkButton ID="LinkButton2" runat="server" CommandName="DELETE"  
    OnClientClick="javascript:return DeleteConfirm(this, Are you Sure? );" CausesValidation="False" Text="Delete" > Delete
</asp:LinkButton>
    function DeleteConfirm(btn, msg) 
    { 
            if(msg==  ){msg= Are You Sure ?  ;}

            if ($(btn).attr( confirmOK )== 1 ){return true;}

              bootbox.confirm({
                    title:  Confirm Popup ,
                    message: msg,                   
                    callback: function(result) {
                             if (result) 
                             { 
                                $(btn).attr( confirmOK ,  1 );
                                 btn.click();
                             }
                             else{
                               $(btn).attr( confirmOK ,  0 );
                             }
                    }
                });

            return false;
     };





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签