Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open JQuery UI popup onclick

I have simple html page:

<html>
<head>
<title></title>
</head>
<body>
  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {
            $("#OpenDialog").click(function () {
                $("#dialog").dialog({modal: true, height: 590, width: 1005 });
            });
        });
    </script>
    <a id="#OpenDialog" href="#">Click here to open dialog</a>
    <div id="dialog" title="Dialog Title">
        <p>test</p>
    </div>

</body>
</html>

I need to have popup content hidden and when click on the link open a dialog.

What I'm wrong with in my code?

Thanks!

like image 378
ihorko Avatar asked Aug 10 '12 17:08

ihorko


2 Answers

id of element is not supposed to have # in it if you want to use jQuery selector as you used in $("#OpenDialog").click(

Change

<a id="#OpenDialog" href="#">Click here to open dialog</a>    

To

 <a id="OpenDialog" href="#">Click here to open dialog</a>
like image 105
Adil Avatar answered Oct 19 '22 03:10

Adil


change the id of the link from #OpenDialog to OpenDialog

like image 7
Raab Avatar answered Oct 19 '22 05:10

Raab