简体   繁体   English

OutputScript无法加载我的JavaScript源

[英]OutputScript doesn't load my JavaScript source

I'm using Primefaces 5.0 and I'm trying to use the "draggableRows" feature. 我正在使用Primefaces 5.0,并且正在尝试使用“ draggableRows”功能。 It works fine but I'm trying to get the reordered list in order to save the new position into database. 它工作正常,但为了将新职位保存到数据库中,我正在尝试获取重新排序的列表。

I tried this implementation: Draggable rows in primefaces datatable - a way to save the order of the table? 我尝试了这种实现: 在primefaces数据表中可拖动的行-一种保存表顺序的方法吗?

Unfortunately, I have no enough reputation to Add a Comment in that question, so I will ask it here: 不幸的是,我没有足够的声誉在这个问题上添加评论,所以我将在这里提出它:

I tried exactly what the answer said, but <h:outputScript name="js/pf.js" target="body"/> doesn't load. 我尝试了答案的正确含义,但是没有加载<h:outputScript name="js/pf.js" target="body"/>

So, I also tried: <script type="text/javascript" src="js/pf.js"/> Then it loads but tabSort is not defined because it can't get the DataTable's widgetVar. 因此,我也尝试过: <script type="text/javascript" src="js/pf.js"/>然后加载,但tabSort因为它无法获取DataTable的widgetVar。

PS: That question is from 2013. Has Primefaces any new feature to do this stuff more easily? PS:这个问题来自2013年。Primefaces是否有任何新功能可以更轻松地完成此操作?

PS2: All the sources is in the question linked above. PS2:所有来源均在上面链接的问题中。 My source is exactly the same. 我的来源是完全一样的。

This code : 此代码:

<h:outputScript name="js/pf.js" target="body"/>

only works if you have a <h:body> and not just a <body> element in your view. 仅在您的视图中具有<h:body>而不只是<body>元素时才有效。

The other reason why your code may not work is the resource path. 您的代码可能无法正常工作的另一个原因是资源路径。 See : Include javascript with resources via h:outputScript 请参阅: 通过h:outputScript在资源中包含javascript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM