* [story #69184, doing] add commands to load lazy contents in DocApp.

This commit is contained in:
sunhao
2024-11-13 09:22:31 +08:00
committed by 刘刚
parent 769756f751
commit b968522c7c
+27
View File
@@ -1027,6 +1027,33 @@ const commands =
$.post($.createLink('doc', 'edit', `docID=${docID}`), docData);
}
});
/**
* 加载懒加载内容。
* Load the lazy content.
*/
loadLazyContent: function(_, args)
{
const selector = args[0];
if(!selector) return;
$(selector).closest('.lazy-content').trigger('loadContent');
},
/**
* 更新懒加载内容。
* Update the lazy content.
*/
updateLazyContent: function(context, args)
{
const event = context.event;
const $element = $(event.currentTarget);
const selector = args[0] || $element.data('lazyTarget');
const $lazy = (selector ? $(selector) : $element).closest('.lazy-content');
const url = $element.data('url') || $element.attr('href');
if(url) $lazy.trigger('loadContent', url);
event.preventDefault();
event.stopPropagation();
},
/**
* 定义页面上的自定义渲染器。
* Define the custom renderers on the page.