2 Replies Latest reply on Jan 11, 2013 6:30 AM by spinacz

    JavaScript file order

    spinacz

      Hi,

      I have template xhtml file for page. I include there head_section.xhtml file where is added few js files"

       

      <h:outputScript library="javascript" name="jquery-min.js" target="head"/> 
       <h:outputScript library="javascript"  name="fancybox/jquery.fancybox-1.3.4.pack.js" target="head"/> 
       <h:outputScript library="javascript" name="jquery.newsticker.pack.js"  target="head"/> 
       <h:outputScript library="javascript" name="ui.tabs.pack.js"  target="head"/> 
       <h:outputScript library="javascript" name="jquery.cookie.js"  target="head"/> 
       <h:outputScript library="javascript" name="jquery.simplemodal.js"  target="head"/>         
      

       

       

      Is possible to force JSF and richfaces 4 load this javascript files after jquery from RichFaces?

       

       

      Can someone explain how it works? I mean about loading js and css file to JSF with RF.

       

      Thanks

      regards.

        • 1. Re: JavaScript file order
          ilya40umov

          Are you placing your h:outputScript into h:head or h:body tag?(If you do put them into h:head, try h:body instead)

          • 2. Re: JavaScript file order
            spinacz

            Hi, sory for a break, i had other tasks to do.

             

            Yes, i tried use "body" instead head. It didn't help.

             

            Now i have this entries in my head_section.xhtml:

             

                                <!-- JSF -->
                                <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
            
                                <!-- RichFaces -->
                                <h:outputScript name="jquery.js" target="head"/>
                                <h:outputScript name="richfaces.js" target="head"/>
                                <h:outputScript name="richfaces-queue.js" target="head"/>
                                <h:outputScript name="richfaces-base-component.js" target="head"/>
                                <h:outputScript name="status.js" library="org.richfaces" target="head"/>
            
                                <!-- FS3 -->
                                <h:outputScript library="javascript" name="jquery-min.js" target="head" rendered="false"/>
                                <h:outputScript library="javascript" name="fancybox/jquery.fancybox-1.3.4.pack.js" target="head"/>
                                <h:outputScript library="javascript" name="jquery.newsticker.pack.js" target="head"/>
                                <h:outputScript library="javascript" name="ui.tabs.pack.js" target="head"/>
                                <h:outputScript library="javascript" name="jquery.cookie.js" target="head"/>
                                <h:outputScript library="javascript" name="jquery.simplemodal.js" target="head"/>
            
            
                                <h:outputScript library="javascript" name="MyScript1.js" target="head"/>
                                <h:outputScript library="javascript" name="MyScritp2.js" target="head"/>
                                <h:outputScript library="javascript" name="MyScript3.js" target="head"/><!--tylko SG-->
            
                                <h:outputScript library="javascript" name="scripts.min.js" target="head"/>
            

             

            In rendered html before </head>, there are ale files in the samse order like above, but javascrip function doesn't work. In the console frome developer tools i saw

            Uncaught ReferenceError: mainFunction is not defined"

            but file with function MyScript1.js is loaded after javascript from JSF and RF4.

             

            probably i miss something, but i have no idea what should i check