javascript - 如何在 dhtmlx Scheduler Lightbox 中添加隐藏字段

标签 javascript jquery dhtmlx-scheduler

我正在尝试修改 dhtmlx 调度程序灯箱,我在这里添加了一些新字段,但现在的问题是我需要一个隐藏字段,并将通过 JavaScript 传递值。但 dhtmlx 调度程序没有隐藏任何字段类型,我无法在那里推送任何自定义类或 id。我知道有一个示例将创建自定义灯箱 View here ,但我不想仅将其用于一个字段。

这是我的代码:

function init() {
    var role = <%= role %> ;
    var custom_form = document.getElementById("custom_form");
    scheduler.config.lightbox.sections = [
        {   name: "Post on",type: "radio",map_to: "post_on",
            options: [
                { key: "facebook", label: '<i class="fa fa-facebook"> </i>' },
                { key: "google", label: '<i class="fa fa-google-plus"> </i>' },
                { key: "twtter", label: '<i class="fa fa-twitter"> </i>' }
            ]
        },
        { name: "files", height: 50, map_to: "files", type: "textarea", focus: true }, //This one need to be a hidden field with a unique class or id
        { name: "text", height: 50, map_to: "description", type: "textarea", focus: true },
        {   name: "Tags: ", type: "multiselect",map_to: "tags",
            options: [
                { key: "funny", label: 'Funny' },
                { key: "promotions", label: 'Promotions' },
                { key: "Branding", label: 'Branding' },
            ]
        },
        {name: "time",height: 72,type: "time",map_to: "auto",},
    ];
    scheduler.config.first_hour = 0;
    scheduler.config.event_duration = (60 * 14) - 10;
    scheduler.config.auto_end_date = true;
    scheduler.config.include_end_by = true;
    scheduler.locale.labels.section_priority = 'Priority';
    // Adding custom button
    scheduler.config.buttons_left = ["dhx_save_btn", "dhx_cancel_btn", "add_file"];
    scheduler.locale.labels["add_file"] = "Add Files";
    scheduler.config.buttons_right = ["dhx_delete_btn", "select_file"]
    scheduler.locale.labels["select_file"] = "Select File";
    scheduler.attachEvent("onLightboxButton", function(button_id, node, e) {
        if (button_id == "add_file") showUploader();
        else if (button_id == "select_file") showFilemanager();
    });
    scheduler.config.xml_date = "%Y-%m-%d %H:%i";
    scheduler.init('scheduler_here', new Date(), "month");
    var user_id = <%= locals.user_id %> ;
    scheduler.templates.xml_date = function(value) { return new Date(value); };
    scheduler.load("/cdata?user_id=" + user_id, "json");
    var dp = new dataProcessor("/cdata?user_id=" + user_id);
    dp.init(scheduler);
    dp.setTransactionMode("POST", false);
    scheduler.templates.event_bar_text = function(text, start, end, event) {
        return "<b>" + end.post_on + "<b> <i>" + end.description + "</i> " + end.tags;
    };
    scheduler.templates.event_bar_date = function() { return ""; };
}

那么是否可以隐藏 files 字段并向其推送一个特殊的类?

提前致谢。

最佳答案

最简单的方法是在 onBeforeLightbox 事件触发时根据您的条件重新定义 Scheduler.config.lightbox.sections。 IE。您需要为灯箱创建 2 个配置:带文件 (1) 和不带文件 (2)。

Check the sample how it works. 隐藏部分仅针对“完全访问”事件显示

关于javascript - 如何在 dhtmlx Scheduler Lightbox 中添加隐藏字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48095115/

相关文章:

javascript - 单元测试 Angular Bootstrap 模式服务

javascript - 在 sequelize 中不使用 dataValues 对象访问变量

javascript - JQuery UI 可拖动根本不起作用!

javascript - 为什么 MVC ajax onSuccess 函数即使状态码是 302 也会被触发

javascript - 在angularjs中的DHtmlX调度程序上添加时间线事件

javascript - AngularJS 中的登录页面

javascript - vue 关于单元测试 - javascript

jquery - 从 jQuery 的多选下拉列表中取消选择所有元素

jquery - DHTMLX 调度程序创建或编辑

java - DHXScheduler 保存/获取自定义灯箱字段