Reputation: 667
I'm using JQuery-Dialog Widget. I want to show the clicked image in pop-up. But with my code, it could not be done as I'm using this widget first time. Below is my code
<html>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
<ul>
<li id="child"><img src="images/child1/image.jpg" /></li>
</ul>
<script>
$('li[id="child"]').dialog({autoOpen: false});
$('li[id="child"]').click(function() {
$('li[id="child"]').dialog("open");
});
</script>
</body>
</html>
I need to open the dialog of same element which is being clicked
Upvotes: 2
Views: 279
Reputation: 178026
This works
$(function(){
$("body").append('<div id="dialog"/>')
$("#dialog").dialog({
height:400, width:500, modal: true, autoOpen:false
});
$('#child > img').on('click', function() {
$("#dialog").html($('<img />', {src:this.src}));
$("#dialog").dialog("open");
});
});
Upvotes: 1
Reputation: 141
Try:
<script>
$(function(){
$('#child > img').on('click', function() {
$(this).dialog('open');
});
$('#child > img').dialog({autoOpen: false});
});
</script>
Upvotes: 0