views:

233

answers:

3
+1  Q: 

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>
+1  A: 

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.

karim79
I did got the alert =/
Luis Armando
Try making a call to DateJS without first loading the jQuery libs, maybe jQuery is interfering?
karim79
nope, I removed the jQuery file, still nothing =( I could actually write the js myself since it's not that difficult, but I don't know how to append it on the fly to the spot where I want it
Luis Armando
Try posting your problem on the datejs mailing list at http://groups.google.com/group/datejs/topics?pli=1 . Put in a link to this question, I must admit it does seem rather odd that it's failing as you described. Someone there should be able to help you.
karim79
+1  A: 

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.

splattne
A: 

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.

Josh Stodola