We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    In order to solve an issue for the aJaxSearch snippet, I need to solve the following issue :

    I use this snippet :
    <?php
    $stripHTML = 1;
    $stripSnip = 1;
    
    $jsVars = <<<EOD
    <script type="text/javascript">
    <!--
    stripHtml = $stripHTML;
    stripSnip = $stripSnip;
    -->
    </script>
    EOD;
    
    $modx->regClientStartupScript($jsVars);
    ?>


    with the following template :
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=[(modx_charset)]" />
    </head>
    <body>
      [!Test!]
    </body>
    </html>


    My test document test has an empty content and is a non-cacheable page.

    With this test context :
    The source code of the result (a blank page, but look at the source code) is :
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<script type="text/javascript">
    		<!--
    		stripHtml = 1;
    		stripSnip = 1;
    		-->
    	</script>
    	<script type="text/javascript">
    		<!--
    		stripHtml = 1;
    		stripSnip = 1;
    		-->
    	</script>
    </head>
    <body>
      
    </body>
    </html>


    I get the javascript initialisation twice >:( with IE6 or FF2.0
    How could avoid that ? Any ideas ? I would like just init javaScript variables
    The use of modx->regClientStartupScript() seems worked correctly. Why i get Two call to this function ?

    If i use [[Test]] instead of [!Test!] in the template, it’s ok, I get the variables initialisation only one time. smiley
    Thanks for your help or any suggestion for a workaround
      • 22303 MODX Staff
      • 10,725 Posts
      FYI, this was a known bug with the $modx->regClientStartup*() API functions in 0.9.6 and was resolved with the 0.9.6.1 release.
      (See http://modxcms.com/bugs/task/865)
        • 5811
        • 1,717 Posts
        Thanks Jason. I have upgraded to 0.9.6.1 and now all seems ok.
        Starting now, i will look at the changelog first wink