【发布时间】:2015-04-30 16:12:14
【问题描述】:
是否可以为 PrimeFaces 时钟小部件设置开始时间? 我知道 PrimeFaces Extensions 的模拟时钟,但我需要带有此选项的数字时钟。 我试图覆盖这个时钟的 javascript 方法,但它不起作用。
PrimeFaces.widget.Clock = PrimeFaces.widget.BaseWidget.extend({
init: function(cfg) {
this._super(cfg);
this.cfg.value = 1430304817141;
this.current = this.isClient() ? new Date() : new Date(this.cfg.value);
var $this = this;
},
isClient: function() {
return this.cfg.mode === 'client';
},
});
【问题讨论】:
-
不工作怎么办?您在哪里尝试覆盖脚本以及如何覆盖?
-
我已尝试在 $(document).ready 函数中覆盖此方法 - 未调用 init 方法。
-
发布您的覆盖代码。
-
上面发布的代码。
this.cfg.value是默认时间,这里这个值被覆盖this.cfg.value = 1430304817141;然后尝试在这里设置这个值this.current = this.isClient() ? new Date() : new Date(this.cfg.value); -
所以你不是在覆盖一个方法,你是在覆盖一个小部件?在
$(document).ready中,它可能会在 PrimeFaces 创建小部件之后覆盖。尝试在h:head中覆盖而不等待ready事件。
标签: jsf-2 primefaces clock