- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试通过指向特定月份的链接来帮助实现此功能
http://jquerymobile.com/test/experiments/ui-datepicker/
我试过了
http://jsfiddle.net/mplungjan/FQLjS/2/
Error: $("#datePicker").datepicker("getDate").getMonth is not a function
Source File: http://fiddle.jshell.net/mplungjan/FQLjS/2/show/
Line: 59
这里存在哪些问题?
请注意移动 jquery 和移动日期选择器添加的资源
最佳答案
该问题是由 jquery.ui.datepicker.mobile.js
引起的,无论您从何处获得该问题,这显然都是不完整的黑客攻击。
真正的问题在于这一行:
//return jqm obj
return this;
这意味着无论你调用什么,它总是会为新的日期选择器返回被黑的 jQuery 对象。在您的情况下,它应该返回一个日期。
一个解决方案,这又只是一个 hack,是保存原始日期选择器调用的返回值,并且仅在原始返回值实际上是 jQuery 对象时才返回 jQuery 对象:
...
//call cached datepicker plugin
var retValue = prevDp.call( this, options );
...
//return jqm obj
if(retValue){
if(!retValue.jquery) return retValue;
}
return this;
...
编辑:这一扩展的进一步问题是它破坏了所有需要多个参数的命令。 datepicker()
最多可以采用 5 个参数,因此这些额外参数必须传递到原始扩展。
同样,额外样式的添加和点击事件的绑定(bind)只能在构建日期选择器时进行,因此需要进行额外的检查以查看第一个参数的类型是否为是否为字符串。
生成的代码应该看起来像这样,我将剩下的留给原始开发人员:)。
(function($, undefined ) {
//cache previous datepicker ui method
var prevDp = $.fn.datepicker;
//rewrite datepicker
$.fn.datepicker = function( options, param2, param3, param4, param5 ){
var dp = this;
//call cached datepicker plugin
var retValue = prevDp.call( this, options, param2, param3, param4, param5 );
//extend with some dom manipulation to update the markup for jQM
//call immediately
function updateDatepicker(){
$( ".ui-datepicker-header", dp ).addClass("ui-body-c ui-corner-top").removeClass("ui-corner-all");
$( ".ui-datepicker-prev, .ui-datepicker-next", dp ).attr("href", "#");
$( ".ui-datepicker-prev", dp ).buttonMarkup({iconpos: "notext", icon: "arrow-l", shadow: true, corners: true});
$( ".ui-datepicker-next", dp ).buttonMarkup({iconpos: "notext", icon: "arrow-r", shadow: true, corners: true});
$( ".ui-datepicker-calendar th", dp ).addClass("ui-bar-c");
$( ".ui-datepicker-calendar td", dp ).addClass("ui-body-c");
$( ".ui-datepicker-calendar a", dp ).buttonMarkup({corners: false, shadow: false});
$( ".ui-datepicker-calendar a.ui-state-active", dp ).addClass("ui-btn-active"); // selected date
$( ".ui-datepicker-calendar a.ui-state-highlight", dp ).addClass("ui-btn-up-e"); // today"s date
$( ".ui-datepicker-calendar .ui-btn", dp ).each(function(){
var el = $(this);
// remove extra button markup - necessary for date value to be interpreted correctly
el.html( el.find( ".ui-btn-text" ).text() );
});
};
if(typeof options != 'string'){
//update now
updateDatepicker();
// and on click
$( dp ).click( updateDatepicker );
}
//return jqm obj
if(retValue){
if(!retValue.jquery) return retValue;
}
return this;
};
//bind to pagecreate to automatically enhance date inputs
$( ".ui-page" ).live( "pagecreate", function(){
$( "input[type='date'], input:jqmData(type='date')", this ).each(function(){
$(this).after( $( "<div />" ).datepicker({ altField: "#" + $(this).attr( "id" ), showOtherMonths: true }) );
});
});
})( jQuery );
关于jquery - $ ("#datePicker").datepicker ("getDate").getMonth 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5926508/
我有一些测试在我的代码上测试 getMonth 方法。 为了一切顺利,我将日期设置为 UTC 0,例如,如果我输入 Date.UTC(new Date (2021, 0, 1))我有一个字符串 202
我有一个带有 production_date 的对象我试图提取年份和月份,但我不断得到 getMonth()和 getYear()不是函数错误... function(d) { v
我有一个包含这样的时刻的模型: 我想要的是从中获取月份。我想要的不是一系列的时刻,而是一系列的月份。 我尝试使用 model.xAxisDates.getMonth() 像图片中那样执行此操作,但它返
我有一个函数,我想用它在一个月后对博客文章进行排序。 function sortBlogPostsAfterMonth(blogData) { console.log(blogData[0].cr
我有一个代码,我在其中测试两个日期之间的月数差异。为了得到旧的约会,我正在做以下事情 var oldDate = new Date(); oldDate.setMonth(oldDate.ge
这个问题已经有答案了: unexpected javascript date behavior (3 个回答) 已关闭 7 年前。 我在今天的日期中添加天数并获取以毫秒为单位的时间戳。 for(i
我正在从数据库中检索日期列表,并从这些日期中获取月份。当我获取该日期的月份时,它会返回一月份的 0。 var date = new Date('2015-12-31T22:57:12.000Z').g
本文整理了Java中cesiumlanguagewriter.YearMonthDay.getMonth()方法的一些代码示例,展示了YearMonthDay.getMonth()的具体用法。这些代码
我正在尝试使用此函数来验证用户是否有 18 年或更长时间,但在使用 getMonth() 时出现不稳定的行为。即如果我输入 1,ir 返回 0,但是如果我输入 2,它返回 2: function va
我已经粘贴了代码。我试图通过 getMonth 方法显示当前月份。我知道它显示一个月(0=一月到 11=十二月)。这就是为什么它在我的案例中显示了九月。我尝试添加 1 (.getMonth()+1)
早上好。 我有一个 jQuery Datepicker 对象,它是使用 javscript Date 对象预填充的,我有 getMonth() 返回 50 作为月份,而不是 5。这在 2012 年 4
我在使用 JavaScript date.getMonth() 和 date.getUTCMonth() 时发现了不一致的结果,但仅限于某些日期。以下示例演示了该问题: Click the bu
这个问题已经有答案了: unexpected javascript date behavior (3 个回答) 已关闭 8 年前。 我知道还有其他关于此的帖子,但我无法弄清楚我在这里做错了什么。下面是
我正在开展一个项目,该项目利用 ICU 的库来处理各种语言的日期信息。我在函数中使用以下代码: UErrorCode uec; Locale locale(language); // e.g with
我正在尝试构建一个 javascript 函数,该函数将自动填充日历中 14 天的日期,直到最后一个日期,该日期由日期选择器选择。到目前为止我的代码是: function filldates() {
本文整理了Java中java.time.ZonedDateTime.getMonth()方法的一些代码示例,展示了ZonedDateTime.getMonth()的具体用法。这些代码示例主要来源于Gi
本文整理了Java中java.time.YearMonth.getMonth()方法的一些代码示例,展示了YearMonth.getMonth()的具体用法。这些代码示例主要来源于Github/Sta
我有一个名为 $F{Fecha} 的时间戳文本字段,我想从中获取日期、月份和年份。我创建了 3 个变量 var1,var2,var3 并且在它们的表达式中我已经把以下 $F{Fecha}.getDay
jquery datepicker 非常有趣,但我遇到了一个奇怪的错误。我试图禁用一些日子,即。 2009 年 10 月 28 日,但 11 月 28 日在日历上被禁用!知道我在这里做错了什么吗? d
我有一种方法来计算给定格式(“yyyy-MM-dd”)的制造日期以及产品可以在 int 中使用之前的月份的到期日期。首先,我尝试使用 getYear getMonth getDate of Month
我是一名优秀的程序员,十分优秀!