Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create JavaScript confirm Model

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 172
    Comment on it

    In the code given below, i have created a javaScript Confirm Model with the help of bootstrap. I also used document ready event handler to trigger the event.Confirm model without a callback isn't particularly useful,but it is entirely possible using the native method .

    //$(document).ready(function() {
            $('a[data-confirm]').click(function(ev) {
                    var href = $(this).attr('href');
                    if (!$('#dataConfirmModal').length) {
                            $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button><h3 id="dataConfirmLabel">Please Confirm</h3></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a class="btn btn-primary" id="dataConfirmOK">OK</a></div></div>');
                    } //$(document).ready(function() {
            $('a[data-confirm]').click(function(ev) {
                    var href = $(this).attr('href');
                    if (!$('#dataConfirmModal').length) {
                            $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button><h3 id="dataConfirmLabel">Please Confirm</h3></div><div class="modal-body"></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a class="btn btn-primary" id="dataConfirmOK">OK</a></div></div>');
                    } Modal').find('.modal-body').text($(this).attr('data-confirm'));
                    $('#dataConfirmOK').attr('href', href);
                    $('#dataConfirmModal').modal({show:TRUE});
                    return false;
            });
    });//
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: