MDL-77712 core_course: Fix exception with inplace editor

* On fresh install, an exception is raised when we try to modify
the name of a newly inserted activity in the front page
This commit is contained in:
Laurent David
2023-04-03 10:43:11 +02:00
committed by Laurent David
parent a78f3a02c6
commit fbbdfefdb6
3 changed files with 4 additions and 3 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -82,6 +82,7 @@ define(
TOGGLE: '.toggle-display,.dropdown-toggle',
SECTIONLI: 'li.section',
SECTIONACTIONMENU: '.section_action_menu',
SECTIONITEM: '[data-for="section_title"]',
ADDSECTIONS: '.changenumsections [data-add-sections]',
SECTIONBADGES: '[data-region="sectionbadges"]',
};
@@ -981,7 +982,7 @@ define(
// The section and activity names are edited using inplace editable.
// The "update" jQuery event must be captured in order to update the course state.
$('body').on('updated', `${SELECTOR.SECTIONLI} [data-inplaceeditable]`, function(e) {
$('body').on('updated', `${SELECTOR.SECTIONLI} ${SELECTOR.SECTIONITEM} [data-inplaceeditable]`, function(e) {
if (e.ajaxreturn && e.ajaxreturn.itemid) {
const state = courseeditor.state;
const section = state.section.get(e.ajaxreturn.itemid);