How Do I Disable a Jquery Script While in Edit Mode?
Permalink 1 user found helpful<script type="text/javascript" src="<?php echo $this->getThemePath()?>/js/jquery.masonry.min.js"></script> <script> $(function(){ $('#masonry').masonry({ itemSelector: '.box', columnWidth: 100, isAnimated: true }); }); </script>
if(!CCM_EDIT_MODE) { //your stuff }
<script type="text/javascript" src="<?php echo $this->getThemePath()?>/js/jquery.masonry.min.js"></script> <script> $(function(){ $('#masonry').masonry({ itemSelector: '.box', columnWidth: 100, isAnimated: true }); }); </script>
With:
<?php if(!CCM_EDIT_MODE) { ?> <script type="text/javascript" src="<?php echo $this->getThemePath()?>/js/jquery.masonry.min.js"></script> <script> $(function(){ $('#masonry').masonry({ itemSelector: '.box', columnWidth: 100, isAnimated: true }); }); </script> <?php } ?>
<?php if(!$c->isEditMode()) { ?> <script type="text/javascript" src="<?php echo $this->getThemePath()?>/js/jquery.masonry.min.js"></script> <script> $(function(){ $('#masonry').masonry({ itemSelector: '.box', columnWidth: 100, isAnimated: true }); }); </script> <?php } ?>
that solved it :-)
thank you guys - another lesson learned.
Tobi
it's been a while but i just faced the same issue.
i added the code given by Mnkras to a view.php of a block. that would load the script not in the header but in the flow of the body.
however that did not work.
when placing the code in the header.php it did work.
does anybody know why that is so and how to place the script code as part of the view.php to avoid having it on every page even when it's not needed? (it's not needed on every page as the js files are only loaded when the corresponding block is on the page)
until then the code stays where it is (in the header) but an answer would be helpful :-)
Cheers,
Tobi
then in javascript elsewhere on the pages using the theme you can just use: