Problem when using jQuery UI in ASP.NET MVC

0

I'm trying to add the "ComboBox Autocomplete" of jQuery UI in my ASP.NET MVC project, but it says that the widget function is not a function.

  

jquery-3.1.1.min.js: 2 jQuery.Deferred exception: $ .widget is not a function TypeError: $ .widget is not a function

I'm following the example steps of the jQuery site ( jQuery UI tutorial ), the difference is that I extracted the scripts for external file and css as well.

I have already linked the scripts needed to use this function, which is in the following order:

<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/jquery-ui.css")">
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/app/cliente/meu-css.css")">

<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-3.1.1.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-ui.min.js")"></script>

<script type="text/javascript" src="@Url.Content("~/Scripts/app/cliente/meu-script.js")"></script>

I have rephased this example in Notepad and it worked, but in the MVC project it did not work.

    
asked by anonymous 08.12.2016 / 18:38

1 answer

0

I was able to find the problem!

Even jQuery being loaded first, my script did not find the function, since I was not passing the '$' in the parameter of my script's function:

(function($){
    $(document).ready(function(){
        $.widget("custom.combobox", {
        ...
    });
})();

I have not yet understood why, in this case, my script can not see jQuery without having to pass the '$' in the parameter, and when I did the same example in notepad did not have to do that. >     

09.12.2016 / 17:42