如何将代码百万美元放在外部javascript文件中? [英] How to put code thymeleaf in an external javascript file?
问题描述
我有一个外部javascript文件,在我的html文件中使用以下标记声明:
I have an external javascript file which is declared in my html file with the following tag:
<script type="text/javascript" th:inline="javascript" th:src="@{/js/gp-aprobarDocumento.js}"></script>
和 gp-aprobarDocumento.js
代码如下所示:
ventanaAprobacion = function(td)
{
/*<![CDATA[*/
idEntregable = $(td).attr("data-row-id");
idVersion = $(td).attr("data-row-version");
alert("la siguiente viene con el texto dle properties");
alert(/*[[${link.menu.page-certificacion-qa-bandeja-entrada}]]*/);
$(function() {
$("#dialog-aprobar-documento").dialog("open");
});
/*]]>*/
}
因此在执行时函数窗口警报显示为空。
Thus when executed the function the window alert is shown empty.
有人知道如何将百万美元表达式放在外部javascript中吗?
Does somebody know how to put thymeleaf expression in a external javascript?
推荐答案
我认为你想做的事情是不可能的,我有一个类似的问题(这里:如何使用javascript变量访问模型属性)
I think what you want to do it's not possible, I have a similar question (here:How do you access a model attribute with javascript variable)
但是在你的情况你可以这样做:
but in your case you can do something like the this:
in html:
<script type="text/javascript" th:inline="javascript" >
var alertVariable = ${link.menu.page-certificacion-qa-bandeja-entrada};
</script>
以及javascript中的以下内容:
and in the javascript the following:
ventanaAprobacion = function(td)
{
...
alert(alertVariable);
...
}
我知道这不是你想要的但是我有同样的问题,我认为没有任何解决方案。
I know that's not really what you want but I have the same problem and I don't think there is any solution.
这篇关于如何将代码百万美元放在外部javascript文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!