I have a problem loading dynamic content into a new JQuery dialog. When I click on the button nothing happens.
My code is below:
<script src="jquery-ui.min.js"></script>
<script>
//$('#dialog').dialog({ dialogClass: 'noTitleStuff' }); ---> CSS
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
height:$(window).height() - 50,
width:$(window).width() - 50,
show: {
effect: "blind",
duration: 400,
},
hide: {
effect: "explode",
duration: 400
}
});
$( "#opener" ).click(function() {
$( "#dialog").dialog({
open: function(event, ui) {
$('#content').load('http://www.google.com');
}
});
});
});
</script>
</head>
<body>
<div id="dialog">
<div class="content"></div>
</div>
<button id="opener">Open Dialog</button>
</body>
In addition to the provided answers so far I would like to mention, that the provided examples are not working "out-of-the-box" because they are trying to load the Google-page. I stumbled upon this issue over the last half an hour until I read in the JQuery documentation:
Just in case anybody else is having this issue and is wondering why the provided examples and JSFiddles are not working as expected.
Your content div has class, not an id. Below code will do the trick.
What you can do is just load html inside that DOM and create dialog.
you have to define the open function in the initial dialog() setup:
And invoke it like so:
jsfiddle
p.s.: you're using
$('#content')
but in the html you defineclass="content"