jQuery dialog popup

后端 未结 6 1849
孤街浪徒
孤街浪徒 2020-12-14 07:34

I am trying to get this dialog popup form to show up when this link is clicked but it does not work for me. I\'ve been working on this for the past three hours and this is g

相关标签:
6条回答
  • 2020-12-14 08:13

    Use below Code, It worked for me.

    <script type="text/javascript">
         $(document).ready(function () {
                $('#dialog').dialog({
                    autoOpen: false,
                    title: 'Basic Dialog'
                });
                $('#contactUs').click(function () {
                    $('#dialog').dialog('open');
                });
            });
    </script>
    
    0 讨论(0)
  • 2020-12-14 08:13

    You can use the following script. It worked for me

    The modal itself consists of a main modal container, a header, a body, and a footer. The footer contains the actions, which in this case is the OK button, the header holds the title and the close button, and the body contains the modal content.

     $(function () {
            modalPosition();
            $(window).resize(function () {
                modalPosition();
            });
            $('.openModal').click(function (e) {
                $('.modal, .modal-backdrop').fadeIn('fast');
                e.preventDefault();
            });
            $('.close-modal').click(function (e) {
                $('.modal, .modal-backdrop').fadeOut('fast');
            });
        });
        function modalPosition() {
            var width = $('.modal').width();
            var pageWidth = $(window).width();
            var x = (pageWidth / 2) - (width / 2);
            $('.modal').css({ left: x + "px" });
        }
    

    Refer:- Modal popup using jquery in asp.net

    0 讨论(0)
  • 2020-12-14 08:16

    It's quite simple, first HTML must be added:

    <div id="dialog"></div>
    

    Then, it must be initialized:

    <script type="text/javascript">
      jQuery( document ).ready( function() {
        jQuery( '#dialog' ).dialog( { 'autoOpen': false } );
      });
    </script>
    

    After this you can show it by code:

    jQuery( '#dialog' ).dialog( 'open' );
    
    0 讨论(0)
  • 2020-12-14 08:16

    You can check this link: http://jqueryui.com/dialog/

    This code should work fine

    $("#dialog").dialog();
    
    0 讨论(0)
  • 2020-12-14 08:33

    Your problem is on the call for the dialog

    If you dont initialize the dialog, you don't have to pass "open" for it to show:

    $("#dialog").dialog();
    

    Also, this code needs to be on a $(document).ready(); function or be below the elements for it to work.

    0 讨论(0)
  • 2020-12-14 08:35

    This HTML is fine:

    <a href="#" id="contactUs">Contact Us</a>                   
    <div id="dialog" title="Contact form">
      <p>appear now</p>
    </div>
    

    You need to initialize the Dialog (not sure if you are doing this):

    $(function() {
      // this initializes the dialog (and uses some common options that I do)
      $("#dialog").dialog({
        autoOpen : false, modal : true, show : "blind", hide : "blind"
      });
    
      // next add the onclick handler
      $("#contactUs").click(function() {
        $("#dialog").dialog("open");
        return false;
      });
    });
    
    0 讨论(0)
提交回复
热议问题