Tsundoku
Tsundoku

Reputation: 9408

Javascript Datejs

I was looking through some pages when I stumbled across this open source JavaScript date library: Datejs. Now I've been trying to use it but everytime I try any function like:

$(function() { Date.today().toLongDateString() } );

or even only

Date.today().toLongDateString()

withing tags, I get errors when the webpage loads, it tells me Date.today() is not a function but it appears as such in the documentation I've been at this for like almost 2 hours now xD it's driving me crazy and I know I just probably overlooked something...

I loaded the:

<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>

Upvotes: 2

Views: 1966

Answers (4)

Nitin
Nitin

Reputation: 735

Try having the JS Console open in Chrome or Firefox or Safari - you will get a much better idea of what the error is. JS Console has saved me hours or even days - I remember how I used to get frustrated about not being able to tell what happened when JS silently failed. But with JS Console it's never a silent fail - you get some hint in the error message however small.

Upvotes: 0

Josh Stodola
Josh Stodola

Reputation: 82483

Your path to the javascript file is incorrect.

OR

You have a syntax error in a Javascript file that is being loaded before this one. I believe the browser will stop trying to interpret the rest of the Javascript as soon as an error occurs.

Upvotes: 0

splattne
splattne

Reputation: 104030

Are your script path and filename correct? You wrote:

<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>

But according to the "Getting Started" page of the project, it should be:

<script type="text/javascript" src="assets/js/dia_hora/date-es-MX.js"></script>

There are two hyphens in the original file: "date-es-MX.js", not an underscore. Or did you rename the file?

Check if the file correctly loads using Firefox Firebug (network tab) or FiddlerTool if you're using Internet Explorer.

Upvotes: 2

karim79
karim79

Reputation: 342625

Sounds like the script is not getting loaded. Put an alert('hello'); at the beginning of the script and see if you get that popup when the page loads.

Upvotes: 0

Related Questions