Lightswitch HTML-禁用CTRL + S功能 [英] Lightswitch HTML - disabling the CTRL + S functionality

查看:223
本文介绍了Lightswitch HTML-禁用CTRL + S功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

事实证明,当您打开添加/编辑"屏幕(对话框或完整屏幕)时,可以按CTRL + S来保存屏幕.这样可以避免我编写的所有验证,也可以禁用Lightswitch自己的保存"按钮,这也无关紧要.如何禁用此功能?

It turns out then when you have an Add/Edit screen open (dialog or full), that you can hit CTRL + S to save the screen. This avoids all validation I have coded, and also does not matter if I have disabled Lightswitch's own save button. How can I disable this?

在浏览或查看屏幕上不会发生这种情况,并且用户只能在其中保存网页

on a browse or view screen, this does not occur and the user is only able to save there web page

推荐答案

禁用 Ctrl + S 的一个选项是删除msls-save-button css类从屏幕的保存按钮.可以在屏幕的创建方法中完成此操作,如下所示:

One option to disable the Ctrl+S is to remove the msls-save-button css class from your screen's save button. This can be done in your screen's created method as follows:

myapp.AddEditScreen.created = function (screen) {
    $(window).one("pagechange", function (e, data) {
        var $page = $("#" + screen.details._pageId);
        var $button = $page.find(".msls-save-button");
        $button.removeClass("msls-save-button");
    });
};

需要使用jQuery移动页面更改处理程序来确保按照我对以下帖子的回答所涉及的方式呈现您的屏幕(并定义了_pageId):

The jQuery mobile pagechange handler is needed to ensure that your screen is rendered (and _pageId is defined) as covered in my answer to the following post:

浏览"模板中的"LightSwitch"选项卡式屏幕

这种方法之所以有用,是因为LightSwitch msls库通过匹配msls-save-button或msls-ok-button类对提交按钮执行vclick.因此,如果删除了msls-save-button类,则无法触发vclick,实际上 Ctrl + S 会被忽略.

This approach does the trick because the LightSwitch msls library executes the vclick against the commit button by matching either the msls-save-button or msls-ok-button classes. Therefore, if the msls-save-button class is removed, the vclick cannot be triggered and in essence the Ctrl+S is ignored.

下面列出了处理快捷键的msls库函数(该函数的末尾涵盖了msls-save-button vclick的处理):

The following lists the msls library function which handles the short-cut keys (the msls-save-button vclick handling is covered at the end of the function):

function _handleScreenKeyboardShortCuts($page, navigationUnit) {
    var buttonsNeeded = navigationUnit._buttonsNeeded,
        showCancel;
    if (!buttonsNeeded) {
        return;
    }
    showCancel = buttonsNeeded.showSaveDiscard ||
        buttonsNeeded.showOkCancel;
    if (!(showCancel || buttonsNeeded.showOk)) {
        return;
    }
    $page.keydown(function (e) {
        if (msls_shell._currentNavigationOperation ||
            $.mobile.popup.active) {
            return;
        }
        if (showCancel && _isCancelShortCutKey(e)) {
            $(".msls-discard-button,.msls-cancel-button",
                $.mobile.activePage).trigger("vclick");
            return false;
        } else if (_isCommitShortCutKey(e)) {
            $(".msls-save-button,.msls-ok-button",
                $.mobile.activePage).trigger("vclick");
            return false;
        }
    });
}

这篇关于Lightswitch HTML-禁用CTRL + S功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆