Databases Reference
In-Depth Information
// uiw references the UI Widget "this"
$.console.log(uiw._scope, 'onchange', this);
var $this = $(this),
optionToChange = uiw.options.datePickerType == 'from' ? 'minDate' : 'maxDate',
selfDate = $.datepicker.parseDate(uiw.options.datePickerAttrs.dateFormat, $this.val(),
{shortYearCutoff: 30})
;
uiw._elements.$otherDate.datepicker('option', optionToChange,selfDate); //Set the
min/max date information for related date option
}); //bind
$.console.groupEnd(consoleGroupName);
},//_create
/**
* Removes all functionality associated with the clarifitFromToDatePicker
* Will remove the change event as well
* Odds are this will not be called from APEX.
*/
destroy: function() {
var uiw = this;
$.console.log(uiw._scope, 'destroy', uiw);
$.Widget.prototype.destroy.apply(uiw, arguments); // default destroy
// unregister datepicker
$(uiw.element).datepicker('destroy');
}//destroy
}); //ui.clarifitFromToDatePicker
})(apex.jQuery);
It is important to understand some of the techniques used. Here are some of the main points for the
foregoing code:
In the filename,
jquery.ui.clarifitFromToDatePicker_1.0.0.js
, a version
number (_1.0.0) was added to the end of the file. This was done to prevent browser
caching on updates to the file. The next time a modification is made to the file, just
update the version number in the filename.
•
•
The overall structure of the JavaScript file uses the jQuery UI Widget Factory
framework. The jQuery UI Widget Factory framework is covered in the Debugging
& Tools chapter toward the end of this topic. This framework is not required when
developing plug-ins, but it does make things easier to manage in the long run.
The entire function is wrapped at the beginning so that you can use the
$
jQuery
notation. If the function was not wrapped, you could still use the
$
notation but
may run into namespacing issues. If you did not want to wrap your function, you
could use
apex.jQuery
instead of
$
.
•