jQuery Datepicker将默认日期设置为“当前月份,当前日期,(当前年份-18)”(jQuery Datepicker Set Default Date to “current month, current day, (current year-18)”)
我有一个jQuery datepicker。 我想将默认日期设置为“当前月份,当前日期,(当前年份-18)”但我在设置defaultDate属性时遇到问题。 显示的默认年份是1920年,据说是1995年。任何人都可以帮忙吗?
我的代码:
HTML
<input type="text" class="datepicker minimumSize" name="BirthDate" id="BirthDate" readonly="readonly"/>
JavaScript的
var d = new Date(); var year = d.getFullYear() - 18; $('#BirthDate').datepicker({ changeYear: true, changeMonth: true, yearRange: '1920:' + year + '', defaultDate: d.getMonth()+d.getDay()+year});
JSFiddle http://jsfiddle.net/jobzky/zg8Le/
I have a jQuery datepicker. I want to set the default date to "current month, current day, (current year-18)" but I have issue when I set the defaultDate property. The default year displayed is 1920 which is supposedly 1995. Can anyone help?
My code:
HTML
<input type="text" class="datepicker minimumSize" name="BirthDate" id="BirthDate" readonly="readonly"/>
JavaScript
var d = new Date(); var year = d.getFullYear() - 18; $('#BirthDate').datepicker({ changeYear: true, changeMonth: true, yearRange: '1920:' + year + '', defaultDate: d.getMonth()+d.getDay()+year});
JSFiddle http://jsfiddle.net/jobzky/zg8Le/
原文:
最满意答案
运行平衡是您的关键问题。 它不属于任何地方的模型。 您需要的是一个ViewModel 。 搜索WPF实现中常见的MVVM或Model-View-ViewModel模式。
基本上,您需要创建一个专门的
Transaction
类(可能称为RegisterTransaction
),它包含每个事务的运行余额的字段。 您需要为每笔交易计算它。 从那里,使用WPF绑定到RegisterTransaction
对象。The running balance is your key problem here. It doesn't belong in the model anywhere. What you need is called a ViewModel. Search around for the MVVM or Model-View-ViewModel pattern which is common in WPF implementations.
Basically, you need to create a specialized
Transaction
class (maybe calledRegisterTransaction
), which contains a field for the running balance for each transaction. You will need calculate it for each transaction. From there, use WPF to bind to yourRegisterTransaction
objects.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
OOP在JavaScript中(OOP In javascript)[2022-04-12]
这是如何完成的: function Car ( name ) { this.name = name; } Car.prototype.fullName = function () { return this.name; } function SpecialCar ( name, variant ) { Car.apply( this, arguments ); this.variant = variant; } SpecialCar.prototype = Object ... -
OOP有什么意义?(What's the point of OOP?)[2024-01-12]
没有实证证据表明,面向对象是人们思考世界的更自然的方式。 在编程心理学领域有一些工作,表明OO不像其他方法更适合。 面向对象的表示似乎没有被普遍使用或不太可用。 简单地采用OO方法并要求开发人员使用这些方法是不够的,因为这可能会对开发人员的生产力以及开发的系统的质量产生负面影响。 这是来自“关于OO表示的可用性”,来自ACM 2000年10月的通信。文章主要将OO与面向过程的方法进行比较。 有很多关于使用OO方法的人如何“思考”的研究(2001年人力资源计算机学杂志,第54期,1995年人机交互,第10卷, ... -
如果你想建立一个测验系统的模型,其中每个问题都包含一个图像(在你的案例中为Roadsign),一个问答选项,你可以这样做: 名为QuestionImage的类(名称,描述) 类名为Question(QuestionImage,question,answer,options) 名为Quiz的类(ArrayList,正确答案的数量等等) 然后每个问题都可以有一个图像,一个问题(这样你也可以提出不同于What does the image show? ),一个正确的答案,以及几个错误的答案。 If you wan ...
-
OOP是安全的,但是如何?(OOP is secure but how? [closed])[2023-11-12]
它绝对不比功能或程序编程更安全,也不安全。 由于安全性取决于程序员,我没有看到面向对象是如何“更安全”的。 It's definitely not more secure than functional or procedural programming, nor less secure. As security lies in the hands of the programmer, I fail to see how OO is "more secure". -
PHP框架OOP模型(PHP Framework OOP model)[2023-09-11]
多年来,我已经编写并维护了庞大的整体式库,而且我离开它后更快乐。 接受我的建议:将应用程序分解为可能有意义的小类。 这对组织以及内存使用很有帮助(一个巨大的PHP类定义会占用大量内存,RAM是PHP脚本中的有限资源)。 使用PHP 5的自动加载机制仅加载当前上下文中需要的类。 我认为Zend Framework的组织和构建方式非常好。 你可能想看看他们如何设计他们的类,以及他们如何组织框架中的大量功能。 至于如何组织工具和辅助对象以及库,我几周前就问过这个问题,并得到了很好的反馈。 实际上,我还没有完成阅读 ... -
寻找更好的OOP方法(Looking for a better OOP approach)[2022-12-05]
Stalk的答案很好,但是当方法只做一件事而且只做一件事时我更喜欢它。 就像现在一样, .refresh()负责两件事。 计算平衡和节省。 我会通过实现.refresh()方法进一步分解它,但在视图中执行此操作。 (另外我将它命名为refresh_balance而不是刷新,刷新意味着我们刷新整个帐户)。 account.refresh_balance() account.save() 这使得.refresh_balance()的逻辑可以改变,但.save()将保持独立,以做它最好的事情。 将模型保存到数据 ... -
关于oop的问题[复制](problem about oop [duplicate])[2022-06-11]
OOP与结构化编程有用的方式非常有用。 您不需要使用函数,因为您可以使用goto语句编写程序来跳转,但这会使代码难以维护和思考。 类似地,OOP将函数和变量组合到对象中,允许您进一步分解代码,并且通过添加抽象,您可以更轻松地思考代码并以更易于维护的方式编写代码。 OOP is useful in the same way structured programming is useful. You don't need to use functions since you can write a progra ... -
您可以通过在init方法中提供默认值来完成此操作 class Trip: NSObject { var userName: String var tripTitle: String var tripSummary: String var fee: Int var departureCountry: String init(userName: String = "", tripTitle: String = "" , tripSummary: String = "" , fee: I ...
-
运行平衡是您的关键问题。 它不属于任何地方的模型。 您需要的是一个ViewModel 。 搜索WPF实现中常见的MVVM或Model-View-ViewModel模式。 基本上,您需要创建一个专门的Transaction类(可能称为RegisterTransaction ),它包含每个事务的运行余额的字段。 您需要为每笔交易计算它。 从那里,使用WPF绑定到RegisterTransaction对象。 The running balance is your key problem here. It does ...