views:

315

answers:

5

What I am trying to accomplish is using jQuery UI dialog method from my own JavaScript source code file. I have this kind of links in the Site.Master

<script src="/Scripts/jquery-1.4.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui.js" type="text/javascript"></script>
<script src="/Scripts/Common.js" type="text/javascript"></script>  

Common.js is my own helper file. jQuery works fine there, but when I try to call for example:

$(document).ready(function() {
    $("#dialog").dialog();
});

I'll get "Microsoft JScript runtime error: Object doesn't support this property or method"

Any ideas why this happens? jQuery Works fine, but jQuery UI doesn't.

Additional question: if I use jquery-ui.js, do I need other files like core, dialog etc. or does it really contain everything?

A: 

Can you confirm that the script references are being loaded? Startup firebug or fiddler and see if you get any 404s.

The following works for me on coderun.com

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<title>jQueryUIV172Application</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css"
type="text/css" media="all" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"&gt;&lt;/script&gt;

<script src="index.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() { 
$("#dialog").dialog(); 
})
</script>
</head>
<body>
<div id="dialog">
Hello
</div>
</body>
</html>
Raj Kaimal
When I start my project, Visual Studio shows that jquery-ui.js is loaded
Tx3
Better start up the Firefox and Firebug, refresh the page with F5 and check if everything under the "Net" tab is loaded fine (black) or whether you have any errors (red).
mare
A: 

Also you might try loading up references to JS files like this:

<script src="<%=Url.Content("~/Scripts/jquery-1.4.2.js")%>" type="text/javascript"></script> 
mare
A: 

I found the problem. I have been using "Telerik Extension for ASP.NET MVC" and it has function called ScriptRegistrar (is that even a word?) which I had to use like this:

<%= Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
                    group.Add("~/Scripts/jquery-1.4.2.min.js")
                    .Add("~/Scripts/jquery-ui-1.8.1.custom.min.js")
                    .Add("~/Scripts/jquery.validate.js")
                    .Add("~/Scripts/Common.js")
            )
%>

Big thanks to everyone who helped me with this problem!

Tx3
Don't forget to mark this as the answer!
Alastair Pitts
A: 

Thanks, I had the same problem which has been resolved.

Abdul Mannan
A: 

Seems like you ahve to register all your script files through this magic 'Registrar' method from Telerik, otherwise the other scripts in the page won't work.

Cosmin