Bug #17570

onContentLoad() is called twice on every page

Added by Tomer Brisker over 1 year ago. Updated 8 days ago.

Status:Closed
Priority:Normal
Assignee:Tomer Brisker
Category:Web Interface
Target version:1.14.1
Difficulty: Team Backlog:
Triaged: Fixed in Releases:
Bugzilla link: Found in Releases:
Pull request:https://github.com/theforeman/foreman/pull/4080

Description

From the jQuery docs:

when calling .trigger() with an event name matches the name of a property on the object, prefixed by on (e.g. triggering click on window that has a non null onclick method), jQuery will attempt to invoke that property as a method.

When the document loads we trigger a `ContentLoad` event, which causes jQuery to execute the function called `onContentLoad` by default. In addition, we attach a listener to the document that catches the `ContentLoad` event and executes the function as well.
We need to either rename the function or remove the extra listener.

Associated revisions

Revision 83afcbec
Added by Tomer Brisker over 1 year ago

Fixes #17570 - Only execute `onContentLoad` once per page

When an event is triggered, jQuery attempts to execute the on<name>
method if it exists for event <name>. We were also manually triggering
the `onContentLoad` every time the `ContentLoad` event was triggered,
leading to the function executing twice on every page.
This commit removes the explicit event listener so that the function
will only execute once.

Revision 78ab8401
Added by Tomer Brisker over 1 year ago

Fixes #17570 - Only execute `onContentLoad` once per page

When an event is triggered, jQuery attempts to execute the on<name>
method if it exists for event <name>. We were also manually triggering
the `onContentLoad` every time the `ContentLoad` event was triggered,
leading to the function executing twice on every page.
This commit removes the explicit event listener so that the function
will only execute once.

(cherry picked from commit 83afcbecbdaac702253f494ff07351a74308b6be)

History

#1 Updated by The Foreman Bot over 1 year ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4080 added

#2 Updated by Daniel Lobato Garcia over 1 year ago

  • Target version set to 1.4.3

#3 Updated by Anonymous over 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal over 1 year ago

  • Legacy Backlogs Release (now unused) set to 210

Also available in: Atom PDF