简体   繁体   English

调用标签页时调用脏表单检查

[英]Call dirty form check when tab called

I have a window.onbeforeunload check for dirty form that works well. 我有一个window.onbeforeunload检查是否脏表,效果很好。

window.onbeforeunload = function () {
    'use strict';
    if (isDirty === 1) {
        return 'You have unsaved changes';
    }
};

I would like to call this when users click on a tab, our tab call look like the following 当用户单击选项卡时,我想调用此选项,我们的选项卡调用如下所示

<li><a href="#scheduling-tab" onclick="return schedulingTabGet('CRFilingScheduling.do', null);">Scheduling</a></li>

The schedulingTabGet code is in another file it is as follows: scheduleTabGet代码在另一个文件中,如下所示:

function schedulingTabGet(url, formId) {
    return getTab('#scheduling-tab', url, formId);
}

function getTab(tabId, url, formId) {
    jQuery.get(url, jQuery(formId).serialize(), function (data) {
        jQuery(tabId).html(data);
    });

    return false;
}

I tried the code sample from JQuery onchange in tabs event but it wouldn't work. 在Tabs事件中尝试了JQuery onchange的代码示例,但无法正常工作。 I am not sure if that is a little different case. 我不确定情况是否有所不同。 Any suggestions? 有什么建议么?

Thanks, 谢谢,

Tom 汤姆

function checkDirty () {
    'use strict';
    if (isDirty === 1) {
        return 'You have unsaved changes';
    }
};

window.onbeforeunload = checkDirty;

function schedulingTabGet(url, formId) {
    var msg = checkDirty();
    if (msg && confirm(msg)) {
        return getTab('#scheduling-tab', url, formId);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM