jquery - 如何修复 Sharepoint Client 对象中的 Datepicker?
问题描述
//Date Picker Object
$(document).ready(function () {
var myCounter = 1;
$(".myDate").datepicker();
$(".myDate").on('focus', function () {
var $this = $(this);
if (!$this.data('datepicker')) {
$this.removeClass("hasDatepicker");
$this.datepicker();
$this.datepicker("show");
}
});
});
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<input class="myDate" type="text" name="inputDate1" size="autofill" placeholder="Select End Date"
style="margin-right: 20px; text-align: right" readonly /></input>
我在将 datepicker js 文件修复到共享点时遇到问题。我尝试了 datepicker() 函数,但它显示“Uncaught TypeError: $(...).datepicker is not a function”。
但实际上我得到了没有共享点内容的ans。我需要在 sharepoint 中工作的流程。你能建议我如何纠正这个问题吗?
提前致谢...
//日期选择器对象 $(document).ready(function () {
var myCounter = 1;
$(".myDate").datepicker();
$(".myDate").on('focus', function () {
var $this = $(this);
if (!$this.data('datepicker')) {
$this.removeClass("hasDatepicker");
$this.datepicker();
$this.datepicker("show");
}
});
});
解决方案
不确定为什么要为 datepicker 添加焦点功能。
下面的脚本在我的本地运行良好。
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<input class="myDate" type="text" name="inputDate1" size="autofill" placeholder="Select End Date"
style="margin-right: 20px; text-align: right" readonly />
<script type="text/javascript">
$(document).ready(function () {
var myCounter = 1;
$(".myDate").datepicker();
//$(".myDate").on('focus', function () {
// var $this = $(this);
// if (!$this.data('datepicker')) {
// $this.removeClass("hasDatepicker");
// $this.datepicker();
// $this.datepicker("show");
// }
//});
});
</script>
用于故障排除。
使用开发者工具检查加载成功的库。
如果库未成功加载,请下载并保存到 SharePoint 并加载表单 SharePoint。
例如:
<script src="/SiteAssets/jquery-1.8.3.js"></script>
<script src="/SiteAssets/jquery-ui.js"></script>
推荐阅读
- scala - Intellij Idea 无法识别 Scala 类中的可变字段,给出“重新分配给 val”错误
- php - 使用 ImageMagick 6.9.3-8 Q16 将 SVG 转换为 png
- javascript - 正文不得超过 1000 个字符
- python - 如何在 Spyder 上使用 OpenCV 运行 Python 面部识别项目
- firebase - 检查用户的电子邮件是否通过firestore验证
- css - 字体未在 Windows Server 2016、IE 中的 Windows 10 中加载
- ios - iOS:在 pod 中使用 Segment-Firebase 时构建 Xcode 项目时出错
- c++ - Qt TreeView获取总行数,考虑的展开和折叠文件夹
- ethereum - 我必须为图书馆创建合同吗?
- apache-kafka - 系统重启后如何找回Kafka的所有topic?