Announcement

Collapse
No announcement yet.

Workaround: JavaScript comments break Variables in Design Preview

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Workaround: JavaScript comments break Variables in Design Preview

    If you have code like
    Code:
    <script type="text/javascript">
    <!--
    var goat='<actinic:variable name="ProductID" encoding="perl" selectable="false" />';
    // -->
    </script>
    Then goat is erronously set to null during the Design Preview.

    Doing without the <!-- and // --> lines fixes things.

    However that's not very good practice so here's a workaround.

    Create two text Variables StartJavaScriptComment and EndJavaScriptComment containing <!-- and // --> respectively. Don't tick any "Place of Setting" boxes so they effectively become constants.

    Then our code block becomes
    Code:
    <script type="text/javascript">
    <actinic:variable name="StartJavaScriptComment"/>
    var goat='<actinic:variable name="ProductID" encoding="perl" selectable="false" />';
    <actinic:variable name="EndJavaScriptComment"/>
    </script>
    And we now get clean code with the JavaScript working as expected.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    #2
    Nice one Norman... don't want the goat being nulled

    I used the same concept in v7 before the introduction of the fabulous Block if to comment out code using a CUSTOMVAR at the site level and then simply hitting the space bar against the 2 variables at section level removed the comment code.


    Bikster
    SellerDeck Designs and Responsive Themes

    Comment

    Working...
    X