Reputation: 9959
My aspx markup is as
<div class="sm08" id="dialog" title="Dialog Title"><asp:Literal ID="litTerms" runat="server"></asp:Literal></div>
and
<asp:HyperLink ID="hp" runat="server" NavigateUrl="#">HyperLink</asp:HyperLink>
How can i load the popup on hyperlink click? Currently the popup is shown at page load.
<script type="text/javascript">
$(document).ready(function () {
$("#dialog").dialog({modal: true, buttons: { "Ok": function() { $(this).dialog("close"); } }});
});
</script>
Thank you in advance
Upvotes: 1
Views: 1779
Reputation: 1172
Add a click listener to your link:
$('#hp').click(function(e){
e.preventDefault();
$('#dialog').dialog('open');
});
Also, you will want to set 'autoOpen' to 'false:
$("#dialog").dialog({autoOpen: false, modal: true, buttons: { "Ok": function() { $(this).dialog("close"); } }});
Upvotes: 1
Reputation: 144659
try this:
$(document).ready(function () {
$('#hp').on('click', function(e){
e.preventDefault() // prevents the default action of the anchor link
$("#dialog").dialog({modal: true, buttons: { "Ok": function() { $(this).dialog("close"); } }});
})
});
Upvotes: 1