title: Richfaces a4j:loadScript clears jQuery plugins on ajax calls
body: <p>I'm loading jQuery embedded into RichFaces with:</p>
  
  <pre><code>&lt;a4j:loadScript src="resource://jquery.js"/&gt;
  </code></pre>
  
  <p>Next, I'm loading the FancyBox jQuery plugin with:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/App/fancybox/jquery.fancybox-1.3.4.pack.js"/&gt;
  </code></pre>
  
  <p>The plugin works ok when the page is first loaded, however after executing an ajax call with</p>
  
  <pre><code>&lt;a4j:jsFunction name="myMethod" data="#{myController.jsonDataToReturn}" action="#{myController.doSomething()}" oncomplete="populateData(data);"&gt;     
    &lt;a4j:actionparam name="selectedTag" assignTo="#{myController.selectedTag}"/&gt;
  &lt;/a4j:jsFunction&gt;
  </code></pre>
  
  <p>the plugin stops working. Tests show that the <code>a4j:loadScript</code> tag is reloaded on every ajax call, thereby reloading the jQuery variable which loses the attached plugin.</p>
  
  <p>The current workaround is to load jQuery by putting a <code>&lt;rich:jQuery query="fn" /&gt;</code> tag somewhere in the page. It does nothing besides forcing jQuery to load, but because it doesn't use a4j, jQuery isn't reloaded on ajax calls.</p>
  
  <p>Still, is there a clean solution for this? I'm using RichFaces 3.3.3 which includes jQuery 1.3.2.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>FancyBox is loaded with:</p>
  
  <pre><code>jQuery(document).ready( function(){
      jQuery('.fancyboxLink').live('click',aclick);
  });
  
  function aclick(){
      jQuery.fancybox({
          href: '#{facesContext.externalContext.requestContextPath}/webpage.xhtml',
              type:'iframe',
              width:710,
              height:510,
              padding:0,
              margin:0,
              hideOnOverlayClick:false,
              overlayColor:'#000'
      });
      return false;
  }
  </code></pre>
  
  <p>After the first ajax call, jQuery no longer contains fancybox.</p>