English 中文(简体)
简单Modal——没有工作——在点击是
原标题:SimpleModal - Callback function not working -- On click of Yes

我想向简单Modal发出习俗确认信息。 但是,用点击是的,它不会触发背靠功能。

on click of close button , I want to fire Simple modal confirm box . I have many places were i want this functionality . That s why dint wanted to hard-code message inside div tag. Please see below code and let me know how can i make this work . thanks in advance .

 jQuery(function($) {




        $( #btn ).click(function(e) {

            e.preventDefault();

            // example of calling the confirm function
            // you must use a callback function to perform the "yes" action
            confirm("", function() {

                window.location.href =  http://www.google.com/ ;
            });


        });



    });

    function confirm(message, callback) {

        // alert("1");
        $( body ).append( <div id="container"><div id="confirm" style="display:none"><div class="header"><span>Confirm</span></div><div class="message">  + message +  </div><div class="buttons"><div class="no simplemodal-close">No</div><div class="yes">Yes</div></div></div><div style="display: none"><img src="skin/img/header.gif" alt="" /><img src="skin/img/button.gif" alt=""/></div></div> );
        $( #confirm ).modal({
            closeHTML: "<a href= #  title= Close  class= modal-close >x</a>",
            resizable: false,
            position: ["20%", ],
            overlayId:  confirm-overlay ,
            containerId:  confirm-container ,
            onButtonClick: function(dialog) {
                var modal = this;

                // if the user clicks "yes"
                $( .yes , dialog.data[0]).click(function() {

                  //  call the callback
                                   if ($.isFunction(callback)) {

                                       callback.apply();
                                   }
                   // close the dialog


                    modal.close(); // or $.modal.close();
                });
            }
        });
    }

罗马尼亚

<!DOCTYPE html>
<html>
<head>
    <title> Confirm Modal Dialog </title> 


    <!-- Confirm CSS files -->
    <link type= text/css  href= skin/confirm.css  rel= stylesheet  media= screen  />
    <!-- JS files are loaded at the bottom of the page -->
</head>
<body>
<input id="btn" type= button  name= confirm   value= Close  onclick="return confirm( Are you sure? );" />   

    <script type= text/javascript  src= jquery/jquery.js ></script>

    <script type= text/javascript  src= jquery/jquery.simplemodal.js ></script>

    <script type= text/javascript  src= jquery/confirm.js ></script>



</body>
</html>
最佳回答

你应该用 j子把确认的方言编码放在网页上。 在电力部装满之后,花gin能够发现“.yes” but子。

Your dialog should already be on the page and set to "display:none". The following code will make any button on your page with the class "confirm" produce a confirm dialog (assuming you have correctly included all the plugin JS files).

CSS:

#confirm {display:none;}

HTML:

<input type= button  class= confirm  value= Click to Confirm />

<!-- modal content -->
<div id= confirm >
    <div class= header ><span>Confirm</span></div>
    <div class= message ></div>
    <div class= buttons >
        <div class= no simplemodal-close >No</div><div class= yes >Yes</div>
    </div>
</div>

JS:

$( .confirm ).click(function (e) {
    e.preventDefault();

    confirm("Confirm yes or no", function () {
        alert( yes clicked );
    });
});

工作实例:

问题回答

暂无回答




相关问题
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: &...

热门标签