Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Jquery modal dialog on click event

Tags:

The below code works fine for only the first click event. However for any subsequent click nothing happens. I tested this on firefox, ie7 but still the same. Am I missing something?

<script type="text/javascript"> $(document).ready(function() {     //$('#dialog').dialog();     $('#dialog_link').click(function() {         $('#dialog').dialog();         return false;     }); }); </script>     </head><body>    <div id="dialog" title="Dialog Title" style="display:none"> Some text</div>      <p id="dialog_link">Open Dialog</p>   </body></html> 
like image 446
Sumanta Avatar asked Jun 08 '09 11:06

Sumanta


2 Answers

try

$(document).ready(function () {     //$('#dialog').dialog();      $('#dialog_link').click(function () {         $('#dialog').dialog('open');         return false;     }); }); 

there is a open arg in the last part

like image 189
almog.ori Avatar answered Oct 21 '22 11:10

almog.ori


Try this

    $(function() {  $('#clickMe').click(function(event) {     var mytext = $('#myText').val();       $('<div id="dialog">'+mytext+'</div>').appendTo('body');             event.preventDefault();          $("#dialog").dialog({                                width: 600,             modal: true,             close: function(event, ui) {                 $("#dialog").remove();                 }             });     }); //close click }); 

And in HTML

<h3 id="clickMe">Open dialog</h3> <textarea cols="0" rows="0" id="myText" style="display:none">Some hidden text display none</textarea> 
like image 42
TigerTiger Avatar answered Oct 21 '22 11:10

TigerTiger