Error: TypeError: $(...).dialog is not a function
Solution 1:
Be sure to insert full version of jQuery UI. Also you should init the dialog first:
$(function () {
$( "#dialog1" ).dialog({
autoOpen: false
});
$("#opener").click(function() {
$("#dialog1").dialog('open');
});
});
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
<button id="opener">open the dialog</button>
<div id="dialog1" title="Dialog Title" hidden="hidden">I'm a dialog</div>
Solution 2:
if some reason two versions of jQuery
are loaded (which is not recommended), calling $.noConflict(true)
from the second version will return the globally scoped jQuery
variables to those of the first version.
Some times it could be issue with older version (or not stable version) of JQuery
files
Solution use $.noConflict();
<script src="other_lib.js"></script>
<script src="jquery.js"></script>
<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
$("#opener").click(function() {
$("#dialog1").dialog('open');
});
});
// Code that uses other library's $ can follow here.
</script>
Solution 3:
If you comment out the following code from the _Layout.cshtml
page, the modal popup will start working:
</footer>
@*@Scripts.Render("~/bundles/jquery")*@
@RenderSection("scripts", required: false)
</body>
</html>
Solution 4:
Change jQueryUI to version 1.11.4 and make sure jQuery is not added twice.