我目前正在使用(它工作正常)
PrimeFaces.widget.OverlayPanel.prototype._old_init = PrimeFaces.widget.OverlayPanel.prototype.init;
PrimeFaces.widget.OverlayPanel.prototype.init = function(cfg)
{
this._old_init(cfg);
this.align();
}但是,我想使用一些更易读和“jQuery”的代码,像这样完全发明了不切实际的代码:
PrimeFaces.widget.OverlayPanel.patch(
{
init: function(cfg)
{
super.init(cfg);
this.align();
},
show: function()
{
console.log('blah blah blah');
super.show();
}
});我尝试过PrimeFaces.widget.Xxx.extend({...}),但在本例中,我无法访问super方法。
拜托,请记住我对Javascript完全是个哑巴
谢谢
发布于 2016-04-19 10:46:57
我做到了:
if(PrimeFaces.widget.OverlayPanel)
{
PrimeFaces.widget.OverlayPanel = PrimeFaces.widget.OverlayPanel.extend(
{
init: function(cfg)
{
this._super(cfg);
this.align();
},
show: function()
{
console.log('blah blah blah');
this._super();
}
});
};这个储存在里面
它被用于全局模板:
<!DOCTYPE html>
<html lang="#{userBean.locale.language}" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:cc="http://xmlns.jcp.org/jsf/composite"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:fn="http://xmlns.jcp.org/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:o="http://omnifaces.org/ui" xmlns:of="http://omnifaces.org/functions"
xmlns:s="http://shapeitalia.com/jsf2" xmlns:sc="http://xmlns.jcp.org/jsf/composite/shape"
xmlns:e="http://java.sun.com/jsf/composite/cc" xmlns:et="http://shapeitalia.com/edea2"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<f:view locale="#{userBean.locale}" contentType="text/html">
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<title><ui:insert name="title">#{navigatorBean.viewTitle}</ui:insert></title>
<link rel="shortcut icon" type="image/x-icon" href="#{resource['favicon/favicon.ico']}" />
</f:facet>
<f:facet name="last">
==========> <h:outputScript name="js/pf-patches.js" /> <==========
<h:outputScript library="omnifaces" name="fixviewstate.js" />
</f:facet>
</h:head>
<h:body>
<h:outputStylesheet name="theme/custom.css" />
<h:outputStylesheet name="theme/other-icons.css" />
...发布于 2016-11-30 14:02:22
我也遇到了同样的问题,但是您的解决方案对我的问题没有100%的效率(请参见这里的https://github.com/primefaces/primefaces/issues/1928)),因为您愿意从OverlayPanel调用_super(),而我正在努力避免它(它做了一些我不想做的事情)。所以我所做的是:
/* Quick fix so layout might be handled in dialog component PF #1928 */
if(PrimeFaces.widget.Layout) {
PrimeFaces.widget.Layout.prototype.init = function(cfg) {
// skip calling PrimeFaces.widget.Layout.init() on purpose
PrimeFaces.widget.DeferredWidget.prototype.init.call(this, cfg);
this.cfg = cfg;
this.id = this.cfg.id;
this.jqId = PrimeFaces.escapeClientId(this.id);
if(this.cfg.full) { //full
var dialog = $(this.cfg.center.paneSelector).parents('.ui-dialog-content');
if(dialog) { // full + dialog
this.jq = dialog;
} else {
this.jq = $('body');
}
} else if(this.cfg.parent) { //nested
this.jq = $(PrimeFaces.escapeClientId(this.cfg.parent));
} else { //element
this.jq = $(this.jqId);
}
this.renderDeferred();
}
}这样,init()就完全被夸大了。(我希望在这种非典型的情况下,它能帮助很少的人;)
https://stackoverflow.com/questions/36594082
复制相似问题