I have a simple handler that calls a method, getDetails() from model, JobService. For unknown reason, the method is run twice. I could not find any duplicate calls in my code.
If I put at the end of the layout file, the method is run once as expected. Any idea?
I tried to debug the issue using debugger module. I was wondering if there is a way to see what processes happened between [preProcess to postProcess]. Thank you.
`
function details(event, rc, prc) {
var id = event.getValue(“id”, “”);
if (isValid(“UUID”, id)) {
prc.job = getModel(“JobService”).getDetails(id);
}
else {
setNextEvent(“main.index”);
}
}
To eliminate some obvious things, I’d use FusionReactor to confirm exactly how many requests are coming from your browser. I’ve had things like hits to /favicon.ico trigger CF code and run an on invalid event which unexpectedly was running code twice when I’d hit F5 a single time in my browser.
You can also use the callStackGet() function to capture exactly how the function is getting called each time.
Thanks for the reply. I was able to narrow down the issue. It was caused by an AJAX JavaScript code that came from a pre-built HTML template.
The weird thing is this AJAX never got called. I commented out the code; and the “run twice” problem is gone.