从脚本手动调用库

Manually calling a library from a script

我正在尝试手动调用 featherlight 库以从脚本制作弹出窗口,但不知道如何制作。文档说:

In cases where you don't want an Element to act as Trigger you can call Featherlight manually. You can use this for example in an ajax callback to display the response data.

$.featherlight($content, configuration);

<script type="text/javascript">
    function validate_help_form() {
        valid = true;
        if (document.help_form.username.value == "") {
            $.featherlight('Error message', $.featherlight.defaults);
            valid = false;
        }
        return valid;
    }
</script>

那么我应该传递什么而不是配置对象来使其工作?

您的内容应该是 HTML(例如 "<p>Error message</p>"、jQuery 选择器(例如 "div.my-class p",其中 'Error message' 被采用)等...阅读不同类型内容的文档