mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
fix: bug where action:settings.sorted-list.loaded fired early
The hook was fired before the elements had been added to the DOM. Also, I updated it to use the new hooks lib.
This commit is contained in:
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
define('settings/sorted-list', [
|
define('settings/sorted-list', [
|
||||||
'benchpress',
|
'benchpress',
|
||||||
|
'hooks',
|
||||||
'jquery-ui/widgets/sortable',
|
'jquery-ui/widgets/sortable',
|
||||||
], function (benchpress) {
|
], function (benchpress, hooks) {
|
||||||
var SortedList;
|
var SortedList;
|
||||||
var Settings;
|
var Settings;
|
||||||
|
|
||||||
@@ -57,13 +58,14 @@ define('settings/sorted-list', [
|
|||||||
form.attr('data-sorted-list-object', key);
|
form.attr('data-sorted-list-object', key);
|
||||||
$('#content').append(form.hide());
|
$('#content').append(form.hide());
|
||||||
|
|
||||||
parse($container, itemUUID, item);
|
parse($container, itemUUID, item).then(() => {
|
||||||
|
hooks.fire('action:settings.sorted-list.loaded', { element: $list.get(0) });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$list.sortable().addClass('pointer');
|
$list.sortable().addClass('pointer');
|
||||||
$(window).trigger('action:settings.sorted-list.loaded', { element: $list.get(0) });
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,13 +115,16 @@ define('settings/sorted-list', [
|
|||||||
var $list = $container.find('[data-type="list"]');
|
var $list = $container.find('[data-type="list"]');
|
||||||
var itemTpl = $container.attr('data-item-template');
|
var itemTpl = $container.attr('data-item-template');
|
||||||
|
|
||||||
app.parseAndTranslate(itemTpl, data, function (itemHtml) {
|
return new Promise((resolve) => {
|
||||||
itemHtml = $(itemHtml);
|
app.parseAndTranslate(itemTpl, data, function (itemHtml) {
|
||||||
$list.append(itemHtml);
|
itemHtml = $(itemHtml);
|
||||||
itemHtml.attr('data-sorted-list-uuid', itemUUID);
|
$list.append(itemHtml);
|
||||||
|
itemHtml.attr('data-sorted-list-uuid', itemUUID);
|
||||||
|
|
||||||
setupRemoveButton($container, itemUUID);
|
setupRemoveButton($container, itemUUID);
|
||||||
setupEditButton($container, itemUUID);
|
setupEditButton($container, itemUUID);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user