简体   繁体   中英

OutputScript doesn't load my JavaScript source

I'm using Primefaces 5.0 and I'm trying to use the "draggableRows" feature. 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?

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.

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.

PS: That question is from 2013. Has Primefaces any new feature to do this stuff more easily?

PS2: All the sources is in the question linked above. 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.

The other reason why your code may not work is the resource path. See : Include javascript with resources via h:outputScript

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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