javascript JSF h:outputScript 排序和 PrimeFaces jQuery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10207011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSF h:outputScript ordering and PrimeFaces jQuery
提问by Thor
I want to use (Primefaces with TwitterBootstrap). Currently the DropDown menu it's not working if e.g. a p:dataTable
is present. I've figured out, that it's working (without any Primefaces components) if I have the following ordering in h:head
:
我想使用(Primefaces with TwitterBootstrap)。当前,如果p:dataTable
存在a,则下拉菜单不起作用。我发现,如果我有以下顺序,它就可以工作(没有任何 Primefaces 组件)h:head
:
<h:head>
<h:outputScript library="js" name="bootstrap.js"/>
<h:outputScript library="primefaces" name="jquery/jquery.js"/>
...
</h:head>
If I swap the ordering (first jquery.js, than bootstrap.js), the DropDown menu is broken. My problem is, that with the usage of PrimeFaces components in the rendered HTML output the scripts used by PrimeFaces (jquery.js and primefaces.js) are always before manual entries in h:head
.
如果我交换顺序(首先是 jquery.js,而不是 bootstrap.js),则下拉菜单会损坏。我的问题是,在呈现的 HTML 输出中使用 PrimeFaces 组件时,PrimeFaces(jquery.js 和 primefaces.js)使用的脚本总是在h:head
.
<script src="/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces"></script>
<script src="/javax.faces.resource/primefaces.js.jsf?ln=primefaces"></script>
<script src="/javax.faces.resource/bootstrap.js.jsf?ln=js"></script>
How can I import bootstrap.js
before jquery.js
?
我bootstrap.js
之前如何导入jquery.js
?
回答by Sebi
If the problem is related to the include order of your resources, you should have a look at the following blog post of the PrimeFaces team: Customizable Resource Ordering.
如果问题与资源的包含顺序有关,您应该查看 PrimeFaces 团队的以下博客文章:可定制的资源排序。
You can define a first
facet inside your h:head
element. Elements placed there will be loaded before the PrimeFaces resources.
您可以first
在h:head
元素内定义一个方面。放置在那里的元素将在 PrimeFaces 资源之前加载。
<h:head>
<f:facet name="first">
<h:outputScript library="js" name="bootstrap.js"/>
</f:facet>
</h:head>