【发布时间】:2014-09-05 10:04:03
【问题描述】:
我想知道如何访问 symfony2 中另一个 html.twig 文件中的 javascript 函数。假设我们有两个 html.twig 文件: file1.html.twig 和 file2.html.twig 。我们也假设他们的代码如下:
file1.html.twig 的代码:
<html>
<head>
<script>
function validate(){
//the code that I need to put here to run the javascript function executer() which exists in file2.html.twig
}
</script>
</head>
<body>
<form id="EventForm" action='{{path('ikproj_groupe_homepaeventsAdd',{id:idg})}}' method="POST" {{ form_enctype(form) }} onsubmit="validate();">
//here is the form content.
</form>
</body>
</html>
file2.html.twig 的代码:
<html>
<head>
<script>
function executer(){
//the function content
}
</script>
</head>
<body>
</body>
</html>
实际上,我想做的是提交 file1.html.twig 中的一个表单,在文件 file2.html.twig 中执行函数 executer() 。是否可以在 Symfony2 中做到这一点??...如果是,我应该在文件 file1.html.twig 的函数 validate() 中放入什么?
【问题讨论】:
标签: javascript html function symfony execution