首页 \ 问答 \ jQuery Datepicker将默认日期设置为“当前月份,当前日期,(当前年份-18)”(jQuery Datepicker Set Default Date to “current month, current day, (current year-18)”)

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/


原文:
更新时间:2022-05-24 22:05

最满意答案

运行平衡是您的关键问题。 它不属于任何地方的模型。 您需要的是一个ViewModel 。 搜索WPF实现中常见的MVVMModel-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 called RegisterTransaction), 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 your RegisterTransaction objects.

相关问答

更多
  • 这是如何完成的: 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 ...
  • 没有实证证据表明,面向对象是人们思考世界的更自然的方式。 在编程心理学领域有一些工作,表明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 ...
  • 它绝对不比功能或程序编程更安全,也不安全。 由于安全性取决于程序员,我没有看到面向对象是如何“更安全”的。 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类定义会占用大量内存,RAM是PHP脚本中的有限资源)。 使用PHP 5的自动加载机制仅加载当前上下文中需要的类。 我认为Zend Framework的组织和构建方式非常好。 你可能想看看他们如何设计他们的类,以及他们如何组织框架中的大量功能。 至于如何组织工具和辅助对象以及库,我几周前就问过这个问题,并得到了很好的反馈。 实际上,我还没有完成阅读 ...
  • Stalk的答案很好,但是当方法只做一件事而且只做一件事时我更喜欢它。 就像现在一样, .refresh()负责两件事。 计算平衡和节省。 我会通过实现.refresh()方法进一步分解它,但在视图中执行此操作。 (另外我将它命名为refresh_balance而不是刷新,刷新意味着我们刷新整个帐户)。 account.refresh_balance() account.save() 这使得.refresh_balance()的逻辑可以改变,但.save()将保持独立,以做它最好的事情。 将模型保存到数据 ...
  • 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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。