MDL-78006 course: register activity chooser listeners just once.
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -44,6 +44,8 @@ const ACTIVITIESRESOURCESREC = 5;
|
||||
const ACTIVITY = 0;
|
||||
const RESOURCE = 1;
|
||||
|
||||
let initialized = false;
|
||||
|
||||
/**
|
||||
* Set up the activity chooser.
|
||||
*
|
||||
@@ -67,6 +69,12 @@ export const init = (courseId, chooserConfig) => {
|
||||
* @param {Object} chooserConfig Any PHP config settings that we may need to reference
|
||||
*/
|
||||
const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
|
||||
// Ensure we only add our listeners once.
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
const events = [
|
||||
'click',
|
||||
CustomEvents.events.activate,
|
||||
@@ -170,6 +178,8 @@ const registerListenerEvents = (courseId, chooserConfig) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user