0

I want to start learning jquery/jquery ui but I seem to be stuck at the most basic step; getting it to load. I've tried with 3 different versions and none of them are working.

In my masterpage:

<link href="Content/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="Content/css/jquery-ui.min.css" rel="stylesheet" />

<script src="Scripts/jquery.js"></script>
<script src="Scripts/jquery-ui.min.js"></script>
<script src="Scripts/bootstrap.min.js"></script>

All of the jquery is from jquery UI download. I've tried with versions from normal jquery site aswell.

When I load page:

enter image description here

Im trying to run just a simple test in html:

<input type="text" name="date" id="date"/>

Script:

<script type="text/javascript">
    $(document).ready(function() {  
        $("#date").datepicker();
    });
</script>
12
  • 2
    Have you tried to wrap your code in document ready handler? $(document).ready(function() { ... }); As 304 is Not Modified so not an issue. Commented Feb 20, 2015 at 7:23
  • That does not help unfortunately =/ Commented Feb 20, 2015 at 7:23
  • 1
    Are there any javascript errors listed in the Console? Commented Feb 20, 2015 at 7:25
  • are you sure the path to jquery is correct? Scripts/jquery.js Commented Feb 20, 2015 at 7:26
  • 1
    post your html regarding #date ?, if it has attribute runat="server" then in asp.net its id gets changed Commented Feb 20, 2015 at 7:32

1 Answer 1

1

A page can't be manipulated safely until the document is ready. jQuery use $(document).ready() for this like.

<script src="Scripts/jquery.js"></script>
<script src="Scripts/jquery-ui.min.js"></script>
<script src="Scripts/bootstrap.min.js"></script>
<script>
$(document).ready(function(){

            $("#date").datepicker();
});  
</script>

If it still does not work.. Use

  if (typeof jQuery != 'undefined') {

        alert("jQuery library is loaded!");

    }else{

        alert("jQuery library is not found!");

    }

to check whether is jQuery is loaded or not. Keep in mind to put this code after where you have loaded the jQuery file.

Check for jQuery UI

if (typeof jQuery.ui != 'undefined') {
  alert("UI loaded");
}
else alert("UI NOT LOADED");
Sign up to request clarification or add additional context in comments.

6 Comments

I get "Jquery library is loaded"
then use $(document).ready() like i have specified above after you load the jQuery file.
You are doing it after loading jquery-ui as well right?
I thought I did since it was in masterpage but when I move the script sources in to default-page before I run the script it works fine. why is this? Im using doc.ready so shouldnt it wait for it to load?.
Please add "Add your sources to header" in answer. Thanks for help :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.