cancel
Showing results for 
Search instead for 
Did you mean: 

Overriding Share Client Side Javascript

vamirr
Champ on-the-rise
Champ on-the-rise
I'm trying to override the Share client side javascript for the people-finder.

The client side javascript resource for this declared in:  people-finder.get.html.ftl.

I have a share extension module that overrides the people-finder.get.html.ftl with the following:


<@markup id="new-js" action="replace" target="js">
      <#– JavaScript Dependencies –>
      <@script src="${url.context}/res/components/people-finder/people-finder-ext.js" group="people-finder"/>
</@>


My new people-finder client code is found in people-finder-ext.js.  


My When the page loads, I can see that both the original people-finder.js and the people-finder-ext.js are loaded.    Why is that?   Shouldn't my @markup with action="replace" be overriding the original reference to people-finder.js?

Setting breakpoints in firebug shows that the people-finder.js is receiving/servicing the events and not people-finder-ext.js.
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

a @markup directive allows you to replace the content it generates / renders. Unfortunately, a @script tag inside the @markup does not render any content - it adds the path to the JS file to a runtime model which is later used to generate content in another @markup.
In effect, it is not possible to remove / replace a @script or @link within a @markup by targeting that @markup.

See <a href="https://issues.alfresco.com/jira/browse/ALF-19976?focusedCommentId=273320&page=com.atlassian.jira.pl...">this JIRA comment by David Draper</a> which outlines the @markup behavior. In Short, you could replace the script if you were to use script without the leading @.

Regards
Axel

vamirr
Champ on-the-rise
Champ on-the-rise
Axel,

Excellent response.  Thank you for the clarification.