Jump to content
Larry Ullman's Book Forums

Chapter 13 Jquery Widget


Recommended Posts

Am I approaching this correctly? I'm trying to produce a datepicker widget but it's not working. Here is the code:

 

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

 

</head>

<body>

<h1>This is a JQuery test of it's plug-ins</h1>

<a href='' id= 'dateInput'><p id= 'pickOne'>Please select a date</p></a>

 

<script src= 'utilities/jquery-1.8.3.js'></script>

<script src= 'utilities/jquery-ui-1.9.2.custom.min.js'></script>

<script src= 'utilities/jquery.ui.datepicker.js'></script>

<script type= 'text/javascript'>$('#dateInput').onclick(function(){$('#pickOne').datepicker();})</script>

</body>

</html>

Link to comment
Share on other sites

I like to be safe than sorry, there has been plenty of times when I forgot that little function and couldn't get the script to work.. :( Even when I tested it it wouldn't work without the ready function.

 

@Christoper, don't forget you can shorten the ready function to this if you like.

 

$(function() {

});

 

 

Basically the point of the post was to have an input element not a paragraph element.

Link to comment
Share on other sites

I rarely use jQuery, so I'm not sure why your scripts sometimes don't work without the ready method, but no script should ever be dependent on the ready method.

The only thing the ready method really gives you is the ability to set up event handlers slightly sooner than you'd be able to with the standard onload event handler. If anything, using the ready method could cause issues that otherwise wouldn't be present.

Link to comment
Share on other sites

 Share

×
×
  • Create New...