Kallel Omar
Kallel Omar

Reputation: 1218

Liferay theme script error: Uncaught SyntaxError: Unexpected token ILLEGAL

I added the following script to a liferay theme to modify the first item title of liferay breadcrumb.

<script type="text/javascript">
    $( document ).ready(function() {
        $("#breadcrumbs li:nth-child(1) a").text('My title');
    });
</script>

but I got the error "Unexpected token ILLEGAL" at this position:

 $( document ).ready(function() {
        $("

I don't know what's the issue exactly, especially jQuery javascript file is included in the head of portal_normal.vm.

In addition I tested the code in the console of the browser and also in a simple html page (not Liferay) and it's working well, but the problem is only with liferay theme.

Upvotes: 0

Views: 734

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48087

Try using jQuery's compatibility mode, e.g. replace $ with jQuery. If your theme utilizes Velocity or Freemarker, these $ terms might be interpreted by the templating engine.

Alternatively, you might want to try escaping the $ sign, some tipps in this SO question

Upvotes: 0

Related Questions