Skip to main content
August 25, 2017
Solved

Javascript Functions Running Twice

  • August 25, 2017
  • 15 replies
  • 7360 views

Hi all -

I'm fairly new to AEM, and have run into an interesting issue. The component I'm building is going to be a financial application that our users fill out. (Think along the lines of filling out an application at a bank to open up a new account.)

I've got a couple of Javascript files in the component, and everything was working great yesterday. Then, at some point, all of my JS functions started running twice. I have one function that logs a "Hello World" to the console when the page is loaded, and it logs that value twice. Same for my jQuery functions - anything that fires on a click runs twice.

I'm not sure what happened to cause this. Like I said, it worked correctly for a while. Any ideas on what might be causing this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Can you try packaging up the app and all the dependencies and try to deploy to a clean install of AEM. Lets rule out an issue with the AEM instance first.

15 replies

August 28, 2017

Here's my page.html under structure/page:

<!--/*
  Copyright 2015 Adobe Systems Incorporated
 
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
 
  http://www.apache.org/licenses/LICENSE-2.0
 
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/-->
<!doctype html>

<html>

  <head>

  <sly data-sly-include="partials/head.html" data-sly-unwrap/>

  <sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>

  </head>

  <body>

  <sly data-sly-include="partials/main.html" data-sly-unwrap/>

  <sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>

  </body>

</html>

It looks like footlibs is only included once. Is there another place I should look to see?

VeenaVikraman
Community Advisor
Community Advisor
August 28, 2017

Which is the clientlibs where your this particular JS is include ? Will it be possible to share a sample code in which this issue is replicable ?

August 28, 2017

Unfortunately, I can't share it publicly due to internal security rules. I could email it to someone, if that's a possibility.

smacdonald2008
smacdonald2008Accepted solution
Level 10
August 28, 2017

Can you try packaging up the app and all the dependencies and try to deploy to a clean install of AEM. Lets rule out an issue with the AEM instance first.

August 30, 2017

That did the trick. I installed a new instance of AEM, and now everything works correctly. Not sure what the problem was, but it's fixed. Thanks!