Hi Everybody - I am trying to get a simple jQuery dialog to show. I have the following:
A view in index.php with the code
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
</body>
</html>
I get the error:
TypeError: $(…).dialog is not a function
$( "#dialog" ).dialog({
which obviously indicates that jQuery-UI is not loaded yet.
What is the best way to address this?
I also tried put the javascript in a seperate file and loading it as follows in the above view:
$this->registerJsFile('common/scripts/test.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
FYI - when I look at the source view, I see that at the end of the file, jquery is loaded as well as follows:
<script src="/ddm/olracddm/ddmscallop/web/assets/7eedbc0c/jquery.js"></script>
this is probably loaded from AppAsset?
Any help will be appreciated …