dataobject_manager 加载它自己的 jquery 文件。当您添加自己的文件时,它会与 dataobject_manager 中的现有文件发生冲突。
您可以查看从 firebug 加载的库。为了做到这一点,
- 打开萤火虫
- 点击“脚本”
- 单击“内联”,将出现一个下拉菜单。如果您键入 jq,则将显示所有包含 jq 名称的文件。它让您了解正在加载的内容。
现在回到您的问题,如果您想使用现有加载的 JQuery,则添加您的自定义文件和验证代码。否则,这里是一个如何显示自定义时间选择器的示例(http://trentrichardson.com/examples/timepicker/)
First, you have to stop/block jquery files from dataobject_manager, if you planning to use your own. Something like this in getRequirementsForPopup() function. Note: It depends which files are loading and which one you want to disable after seeing loaded files in firebug.
requirements::block("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js");
requirements::block("dataobject_manager/javascript/dom_jquery_ui.js");
requirements::block("sapphire/thirdparty/jquery-ui/jquery-ui-1.8rc3.custom.js");
requirements::block("dataobject_manager/javascript/dataobject_manager.js");`
requirements::block("dataobject_manager/javascript/dataobject_manager_popup.js");
Then, you have to include your own jquery files
Requirements::javascript('azeem/javascript/jquery-ui/js/jquery-1.7.2.min.js');
Requirements::javascript('azeem/javascript/jquery-ui/js/jquery-ui-1.8.23.custom.min.js');
Requirements::javascript('azeem/javascript/timepicker/jquery-ui-timepicker-addon.js');
Requirements::javascript('azeem/javascript/timepicker/azeem-timepicker.js');
Requirements::css('azeem/javascript/jquery-ui/css/smoothness/jquery-ui-1.8.23.custom.css');
Requirements::css('azeem/css/timepicker/jquery-ui-timepicker-addon.css');
Here azeem-timepicket.js contains the custom code which you want to add to your fields
//JQuery UI datepicker and timepicker for azeem Event End Date/Time Field
$j('#DataObjectManager_Popup_AddForm_EventEndDate-date, #DataObjectManager_Popup_DetailForm_EventEndDate-date').datepicker({
dateFormat: 'dd/mm/yy'
});
$j('#DataObjectManager_Popup_AddForm_EventStartDate-time, #DataObjectManager_Popup_DetailForm_EventStartDate-time').timepicker({
timeFormat: 'hh:mm'
});
In getCMSFields() function, you have to disable default date picker option, in case you are using date/datetime field.
$startDate = new DatetimeField('StartDate', 'Start Date / Time');
$startDateField = $startDate->getDateField();
$startDateField->setConfig('showcalendar', false);
$startTimeField = $startDate->getTimeField();
$startTimeField->setConfig('showdropdown', false);
$fields->addFieldsToTab('Root.Main', $startDate);
You can verify again in firebug, whether you custom and all other files are loading or not. Same things can be done for your own validation.
Hope it will help.