【问题标题】:Stop users from removing subdocuments in Autoform阻止用户在 Autoform 中删除子文档
【发布时间】:2016-07-21 14:18:58
【问题描述】:

应该发生的情况是用户可以使用大 [+] 按钮添加子文档,但在没有提示的情况下无法将其删除。基本上只是删除 [-] 按钮。我怎么做?我可以这样做吗?

如果无法完成,我有其他解决方案来解决我的问题,但这似乎违背了使用此包的目的。

【问题讨论】:

    标签: meteor meteor-autoform


    【解决方案1】:

    是的,您可以删除 [-] 按钮。

    要添加新文档,您必须在事件中编写以下代码。

    Template.TemplateName.events({  
        "click .autoform-add-item" :function(){
           //This allow to remove the current [-] button as well.
            setTimeout(function(){
                $('.autoform-remove-item').remove();
            });
        },
    });
    

    对于添加编辑文档,您还必须在 onRendered 块中添加删除 [-] 按钮代码,例如:

    Template.TemplateName.onRendered(function () {
        $('.autoform-remove-item').remove();
    });
    

    @Note :: 请确保您在 [+] 按钮上有“autoform-add-item”类,在 [-] 按钮上有“autoform-remove-item”。您可以使用检查元素检查这些类。

    【讨论】:

    • 啊,我希望有一个 Autoform 原生解决方案,但我想这不是 Aldeed 在这个阶段想要支持的东西。
    猜你喜欢
    • 1970-01-01
    • 2023-03-28
    • 2022-11-26
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 2021-10-20
    • 1970-01-01
    • 2013-12-11
    相关资源
    最近更新 更多