时间选择器,.selector不工作 [英] Time picker, .selector not working
问题描述
我使用了时间选择器代码来自
http://www.jqueryscript.net/time-clock/Easy-Time-Selector-with-jQuery-jQuery-UI-timeselect.html
I have used time picker code from the
http://www.jqueryscript.net/time-clock/Easy-Time-Selector-with-jQuery-jQuery-UI-timeselect.html
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/flick/jquery-ui.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="~/Scripts/date-en-US.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.ui.timeselect.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#<%=txtTimePicker.ClientID%>').timeselect({
autocompleteSettings:
{
autoFocus: true
}
}
);
});
<script>
<asp:TextBox ID="txtTimePicker" runat="server" />
我收到以下错误:
0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'timeselect'。请帮帮我..
I am getting the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'timeselect'. Please help me..
推荐答案
(document).ready(function(){
(document).ready(function(){
('#<%= txtTimePicker.ClientID%>')。timeselect({
autocompleteSettings:
{
autoFocus:true
}
}
);
});
< script>
< asp:TextBox ID =txtTimePickerrunat =server/>
('#<%=txtTimePicker.ClientID%>').timeselect({ autocompleteSettings: { autoFocus: true } } ); }); <script> <asp:TextBox ID="txtTimePicker" runat="server" />
我收到以下错误:
0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'timeselect'。请帮帮我..
I am getting the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'timeselect'. Please help me..
好吧,我们假设对象未定义;实际上,异常消息间接证实了它。有关ClientID
行为的详细信息(与直接使用HTMLid
属性相反),请参阅:
https://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode%28v=vs.110%29.aspx [ ^ ],
https: //msdn.microsoft.com/en-us/library/system.web.ui.clientidmode%28v=vs.110%29.aspx [ ^ ]。
它没有这样的属性(方法也是属性),就是这样。这只是DOM元素的包装,没有别的。更重要的是,它不能有这种方法。让我们来看看;如果你正确使用jQuery(很可能,你正确地执行它,除非你隐藏了样本中的一些代码),你显示的代码就是脚本的开头,所以这段代码根本没有机会添加任何属性(函数与否)到jQuery DOM对象包装器。此外,此元素只是一个HTML输入
元素,可以从您唯一的ASP.NET标记中看到。
基本上,您没有使用与日期/时间选择器相关的任何内容。是的,就这么简单。仔细阅读您引用的代码。毕竟,你可以找到更多: http://bfy.tw/1Htu [ ^ ]。
祝你好运。
-SA
All right, let's assume the object is not undefined; actually, the exception message indirectly confirms it. For the detail of the behavior ofClientID
(in contrast to the direct use of HTMLid
attribute), please see:
https://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode%28v=vs.110%29.aspx[^].
It does not have such property (method is also a property), that's it. This is merely a wrapper of an DOM element, nothing else. More importantly, it cannot have this method. Let's see; if you are using jQuery correctly (most likely, you do it correctly, unless you hide some of the code from your sample), the code you show is the very beginning of your scripts, so this code simply has no chance to add any properties (functions or not) to the jQuery DOM object wrapper. Also, this element is just an HTMLinput
element, which can be seen from your only ASP.NET tag.
Essentially, you are not using anything related to a date/time picker. Yes, as simple as that. Read the code you referenced thoroughly. After all, you can find a lot more: http://bfy.tw/1Htu[^].
Good luck.
—SA
这篇关于时间选择器,.selector不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!