In a recent article I looked at the EXT JS JavaScript library and gave a brief overview of what it does and what it contains. In this article we’re going to look at implementing one of the many widgets that come with the library – the date picker widget.
Using the EXT JS Date Picker Widget - Finishing continued (Page 4 of 4 )
We can add a listener for this event very easily by specifying it in the configuration object passed to the date picker constructor. Change the constructor so that it appears as follows (new code is again shown in bold):
//create the date picker
var myDP = new Ext.DatePicker(
{
startDay: 1,
listeners: {
'select':selectHandler
}
}
);
The listeners property accepts an object literal listing the event to listen for as a property key and the handler function as the property value. Try the code out now; it should do everything that we set out to achieve. For reference, the complete file should now appear as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Using the widgets and other classes provided by EXT JS is easy and intuitive, and can help you to quickly and easily create robust and attractive interfaces. The widgets are styled to a professional degree and work exactly as the API describes.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.