.tpl ファイル ("comment_form.tpl") に次のコードがあります。このファイルは、3 つの異なる .tpl ファイル (「file_a」、「file_b」、および「file_c」) に 1 回ずつ含まれます。最後に、これら 3 つのファイルが別の .tpl ファイル ("somefile.tpl") に含まれています。
<script type="text/javascript">
$(document).ready(function Hide() {
document.getElementById('div').style.display = 'none';
</script>
したがって、基本的に、「comment_form.tpl」は次のように「somefile.tpl」に3回ロードされます。
.....
</div><!-- .span9 -->
{include file="includes/file_a.tpl"} // includes "file_a.tpl" which already includes "comment_form.tpl" (which contains the code).
</div>
.....//some code
{include file="includes/file_b.tpl.tpl"} // "includes file_b.tpl" which already includes "comment_form.tpl" (which contains the code).
問題は、コードが初めて機能することです。のように、「comment_form.tpl」が「somefile.tpl」にロードされる 3 つの場所のうち、ターゲット「div」は最初の 1 回だけ非表示になります。次の 2 つの場所では、フォーム (div) は隠されていません。私は十分に明確であることを願っています。何が原因でしょうか??