We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12410
    • 353 Posts
    Hi Guys,
    Using a TV so the user can set a slider transition. Original slider code is
    	<script language="javascript">
    		
    			$(document).ready(function (){
    					$("#pikame").PikaChoose({autoPlay:true, speed: 5000, transition:[0]});
    					$("#id").PikaChoose({IESafe:true});
    					
    				});


    I amended it to:
    	<script language="javascript">
    		
    			$(document).ready(function (){
    					$("#pikame").PikaChoose({autoPlay:true, speed: [[*slider_speed]], transition:[[[*slider_transition]]]});
    					$("#id").PikaChoose({IESafe:true});
    					
    				});


    so a user defined TV will populate the value eg for transiotion 1-10 or speed 1000 - 10000. Anyway the slider_speed TV pulls in the value fine but not the slider_transition. For some WEEEIRD reason the fix is putting a commented out [[*slider_transition]] above the opening script tag <script

    so here is the weirdest of solutions.


    	
    <!--[[*slider_transition]]-->
    
    <script language="javascript">
    		
    			$(document).ready(function (){
    					$("#pikame").PikaChoose({autoPlay:true, speed: [[*slider_speed]], transition:[[[*slider_transition]]]});
    					$("#id").PikaChoose({IESafe:true});
    					
    				});

    ..somehow the value say 3 then passes to transition:[[[*slider_transition]]]}); with the comment set above. I thought commenting out deactivated code and not initialised stuff? smiley

    Anyway is there better way to do this. Feeling guilty that I found a poxy hack to fix it! smiley
    Is there a way for using TV’s in JS?

    THANKS


      • 28042 ☆ A M B ☆
      • 24,524 Posts
      HTML comments only indicate to your browser what to ignore. The MODx parser isn’t effected by them. MODx tags will be processed regardless.

      I think the problem is the extra brackets around the second TV are confusing the MODx parser. I would include those brackets in the TV’s value, or use a snippet to output the TV’s value with the brackets.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 12410
        • 353 Posts
        Thanks the addition of brackets to tvs values worked. Snippet idea didnt stranfely though the code renders now as:
        ... transition:0});


        instead of

        ... transition:[0]});


        with the square brackets. I wonder is there any syntax just for this scenario maybe `[[*mytv]]``or something i havent found. The only draw back is the user is selecting [0] in the tv droptown instead of 0. Not major I suppose but some client will knit pick it.

        Thanks
          • 12410
          • 353 Posts
          I reverted back to the original tv values without the brackets.

          The original

          transition:[0]})
          ; code works the same as

          transition: 0});
          so I dropped the tv in as


          transition:[[*slider_transition]]});


          Thanks for pointer!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            A space also might work... [ [[*blah]] ] since Javascript doesn’t care, and that should make MODx ignore the first and last brackets.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 12410
              • 353 Posts
              Yep that works too! Renders now as [ 0 ] instead of [nospace0nospace]- I can’t even write it here. It disappears, Maybe the square bracket syntax should be replaced by some Arabic or swahili symbol to avoid the conflict. http://www.adinkra.org/htmls/adinkra_index.htm smiley

              God knows how my commenting out made it work?

              Thanks - Will go with this version