Using Javascript In Templates

Summary

  •  Detect edit mode with sitecakeGlobals.editMode boolean and turn your script off

Example

It happens that some specific javascript you want to use can make problems in SiteCake editing mode. In that case solution is to exclude that script in edit mode. There is a boolean sitecakeGlobals.editMode that you can use for edit mode detection.

So if you want to turn off some js,  put similar script in the header of your page:  

<script type="text/javascript">
    $(function() {
        if (window.sitecakeGlobals && sitecakeGlobals.editMode !== true ) {
            $.getScript('js/yourscript.js');
        }
    });
</script>