Uncaught TypeError: Cannot read property 'replace' of undefined

Permalink 3 users found helpful
Hi
I'm facing a very weird problem. I'm using Concrete 5.7.3.1. I'm developing a theme and installing it. Now while editing the site content, it shows the below error:

Uncaught TypeError: Cannot read property 'replace' of undefined underscore.js:1

Note: There is no js file for this theme. Its showing the top bar but not allowing me to edit any area. I've triple checked all my coding and nothing wrong. Can anyone tell me what might cause this and how to fix.

Thanks

ronyDdeveloper
View Replies: View Best Answer
AndyJ replied on at Permalink Reply
Hi Rony,
did you get to the bottom of this. I'm having the same issue with 5.7.4 but I didn't have the issue with 5.7.3.1. It is quite perplexing.
ronyDdeveloper replied on at Permalink Best Answer Reply
ronyDdeveloper
Hey
I'm not sure whats wrong in your end but what I've done wrong was in header.php file. I coded it like below:
<a href="<?php echo BASE_URL.DIR_REL?>" class="navbar-brand">
<?php 
  $a = new GlobalArea('Logo');
  $a->display();
?>
</a>


A global area underneath anchor tag was causing error and prevent me to do anything. After doing a decent amount of R&D I figured it out. Hope this might help.

Rony
zanedev replied on at Permalink Reply
zanedev
fixed it for me also thanks!
ancode replied on at Permalink Reply
Exactly the same situation; created a header.php file, placed an anchor and inside it a block so a brand logo can be customized. Then suddenly the edit mode crashes and throw the same error.

<a class="navbar-brand smoothScroll" href="#my_content">
  <?php
     $a = new Area('my_navbar_logo');
     $a->display($c);
   ?>
</a>

solved when I changed the anchor by a div

Thanks!
AndyJ replied on at Permalink Reply
Hi Rony,
did you get to the bottom of this. I'm having the same issue with 5.7.4 but I didn't have the issue with 5.7.3.1. It is quite perplexing.
graydog replied on at Permalink Reply
graydog
I had the same problem. This was my solution. Move the anchor tag into the PHP code and the Javascript error disappears.

<?php
    $a = new GlobalArea('Logo');
    $a->setBlockWrapperStart('<a href="/" class="logo">');
    $a->setBlockWrapperEnd('</a>');
    $a->display();
?>
mrjcgoodwin replied on at Permalink Reply
mrjcgoodwin
This fix also worked for me :-)