I am attempting to implement this simple example. However, the Javascript isn't working (all the content is showing at all times, no tab 'switching' is occurring). All the JS files are hosted locally.
In my head content placeholder:
<link rel="stylesheet" type="text/css" href="jquery-ui.css">
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script type="text/javascript">
// not working
$(document).ready(function () {
$("#tabs").tabs();
});
</script>
In my main body content placeholder:
<div id="tabs">
<ul>
<li><a href="#tabs-1">One</a></li>
<li><a href="#tabs-2">Dos</a></li>
<li><a href="#tabs-3">Drei</a></li>
</ul>
<div id="tabs-1">
<p>Blah blah blah.</p>
</div>
<div id="tabs-2">
<p>Blah some more.</p>
</div>
<div id="tabs-3">
<p>Blah again.</p>
</div>
</div>
So far from searching SO and wherever else Google has taken me, this is what I've found and tried (with results for each listed):
Wrap the jQuery code in
$(document).ready(function () { // code here });rather than a simple function ($(function() { $( "#tabs" ).tabs(); });). It doesn't work either way.Instead of
$("#tabs").tabs();, use$("#<%= tabs.ClientID %>").tabs();so that .NET can get the ID of the html element. In addition to not working, this also produces the error:tabs does not exist in the current context.Place the JavaScript in the same content placeholder as the #tabs div tags. Still doesn't work.
Add
runat="server"to the #tabs div tag. Still doesn't work.Delete the designer file, then right click on the aspx file and select "Convert to Web Application". This doesn't work because this is already a web application and there is no designer file.
I can't figure out what else to do to make it work.
UPDATE: I was asked to view my browser console logs and found the following:
- One of the JS files is giving a
HTTP/1.1 401 Unauthorizederror. I noticed it was blocked and I unblocked it from the file system, but it still isn't working.
runat="server"on the tags would you need to do$("#<%= tabs.ClientID %>").tabs();.