JQUERY UI DIALOG IS NOT OPENING ON BUTTON CLICK WHEN AUTO OPEN IS SET TO FALSE

Hugh Jackman

Total Post:51

Points:359
Posted by  Hugh Jackman
 1272  View(s)
Ratings:
Rate this:

I’m using asp.net forms this page I’m working on has a master page it works great when autopen is false but when auto false is true I don’t know why it doesn’t work. Code is. 

$(document).ready (function () {
 
         $("#dialog").dialog({
            autoOpen:false,
            appendTo:"form",
 
            show: {                effect: "fade",
               duration: 1000
            },
                             hide: {
                effect: "explode",
                duration: 1000
            },
 
            buttons: {
                Ok: function () {
                    $("[id*=btnmsgOk]").click();
                    $(this).dialog("close");
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
 
 });

and i call this function by this.. 

$('<%=btnSave.ClientID %>').click(function () {
             $("#dialog").dialog("open");
          });

but it dosent work.

  1. Elena Glibart

    Post:42

    Points:296
    Re: JQuery ui dialog is not opening on button click when auto open is set to false

    I have tried following, it is working fine. Please note that , you have missed to put # in jquery selector. It should be $('#<%=btnSave.ClientID %>').click...

    $(document).ready(function() {
      $("#dialog").dialog({
        autoOpen: false,
        appendTo: "form",
        show: {
          effect: "fade",
          duration: 1000
        },
        hide: {
          effect: "explode",
          duration: 1000
        },
        buttons: {
          Ok: function() {
            $("[id*=btnmsgOk]").click();
            $(this).dialog("close");
          },
          Cancel: function() {
            $(this).dialog("close");
          }
        }
      });
    });
    $("#clicktoopen").click(function() {
      $('#dialog').dialog('open');
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/humanity/jquery-ui.css" type="text/css" />
    <div id="dialog">DIV</div>
    <button id="btnmsgOk" value="btn" style="display:none">Ok</button>
    <button id="clicktoopen" value="click">Click</button>

      Modified On Apr-01-2015 07:53:46 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!