iliain/silverstripe-popup

为CMS添加一个字段以快速生成弹出窗口

安装: 9

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 1

开放问题: 0

类型:silverstripe-vendormodule

1.0.0 2023-08-08 04:02 UTC

This package is auto-updated.

Last update: 2024-09-08 06:26:39 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

为CMS添加弹出字段,以便快速构建弹出表单。

感谢sheadawson为其原始Linkable模块的贡献,使我能够模仿他的entwine使用来设置此模块。

安装(使用composer)

composer require iliain/silverstripe-popup

配置

待办事项

用法

您可以如此实现PopupField

// necessary config
$customLink = '/PopupForms/form';
$customBodyJS = <<<JS
    // custom js goes here
JS;

// method A
PopupField::create('PopupForm', 'I am a popup', $customLink, $customBodyJS);

// method B
PopupField::create('PopupForm', 'I am a popup')
    ->setFormURL($customLink)
    ->setFormCustomCode($customBodyJS);

您需要提供自己的URL以从其中加载表单HTML,以及JS来设置弹出窗口的功能/提交方式。这些将为您插入到现有的弹出表单代码中。没有这些,弹出窗口将打开但无法加载任何内容/提交。

自定义JS示例

// On Button Click
this.getDialog().on('click', 'button', function () {
    $(this).addClass('loading ui-state-disabled');
});

// On Submit
this.getDialog().on('submit', 'form', function () {
    const options = {};
    options.success = function (response) {
        const button = self.getDialog().find('button');
        $(button).removeClass('loading ui-state-disabled');
    };

    $(this).ajaxSubmit(options);

    return false;
});

请参阅文档以获取完整示例

待办事项

  • 添加更多自定义函数?
  • 测试同一页面上激活的多个弹出窗口