1 Reply Latest reply on Jul 10, 2012 5:33 AM by Sanjeev Shrestha

    Javascript Problem

    Sanjeev Shrestha Novice

      As I looked into the forums I found many many discussion which said that If the javascript is not detected then add the <h:head> tag and it will get the javascripts and css. Well, this helped in many many cases.

       

           But I have a file called masterTemplate.xhtml and it used by another file(say xyz.xhtml). Now when I include the head tag in masterTemplate.xhtml the corresponding javascript and css are shown. but the including file's (xyz.xhtml's) javascript is shown to have errors. What could be the problem for this. Any ideas or suggestions :

       

      In masterTemplate.xhtml

      <h:head>   

      <ui:insert name="js">

          <script type="text/javascript">

              function validatePage(){

                  return true;

              }

          </script>

      </ui:insert>

      </h:head>

       

      Similarly in xyz.xhtml

       

      <ui:define name="js">

       

              <script type="text/javascript">

              //<![CDATA[

      function myname(){

           alert("My name");

      }

      // ]]>

             </script>

            

      </ui:define>

       

      However, If I remove the <h:head> the the javascript in xyz.xhtml works. Do you have any clues.

        • 1. Re: Javascript Problem
          Sanjeev Shrestha Novice

          I just did this and it ran :

           

          <head>   

          <h:head />

          <ui:insert name="js">

              <script type="text/javascript">

                  function validatePage(){

                      return true;

                  }

              </script>

          </ui:insert>

          <head>

           

          Just remember to keep it on top so that there are no issues with other javascript you are using.