Home > DeveloperSection > Forums > JQuery ui dialog is not opening on button click when auto open is set to false
Hugh Jackman
Hugh Jackman

Total Post:52

Points:366
Posted on    April-01-2015 7:35 AM

 JavaScript JQuery  Jquery UI 
Ratings:


 1 Reply(s)
 700  View(s)
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.



Elena Glibart
Elena Glibart

Total Post:35

Points:128
Posted on    April-01-2015 7:50 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick