views:

4342

answers:

2

Hi all, 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?

The below code works fine if i click the

<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>
+3  A: 

try

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

there is a open arg in the last part

almog.ori
Sorry no luck :(I put an alert("kkh"); before $('#dialog').dialog();and it comes fine but no window yet.
Sumanta
check your references on the clientside, i use firebug to check that there are no 404s
almog.ori
also is this in an updatepanel?
almog.ori
+3  A: 

Hi 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>
Wbdvlpr
Great solution - I liked this!
Guy