0

IE是我存在的祸根。基本上,如果用户尝试跳过选项卡,我想从选项卡中的按钮运行验证,以防止他们不填写数据并可能破坏我的数据库查询。

      $("[id$='tab_TabContainer1_TabPanel2']").click(function (e) {
        var container = $find('TabContainer1');
        if (event.preventDefault) {
            event.preventDefault(); //works for anything with preventDefault (e.g., not called from html onclick, etc.)
        }
        else {
            event.returnValue = false;      //supposed to be IE specific - on global event 'event'
        }

        $("[id$='Button1']").click();   //perform the button1 click event (which calls custom validation)

        if (Page_IsValid) {
            container.set_activeTabIndex(1); //go ahead to next tab
        }
        else {
            container.set_activeTabIndex(0);    //stay here on current tab
        }
        return false;
    });

应该就是这么简单,上面的方法在firefox/google chrome中有效,但在IE8中无效。IE8 只是在验证后转到下一个选项卡,不管任何事情。即使我返回 false;立即,它只是转到下一个选项卡。蜜獾不在乎,蜜獾只是转到下一个标签。有任何想法吗?

4

1 回答 1

0

您的问题在于使用“事件”而不是您实际调用事件的 e 。如下所示将事件更改为 e,它应该可以正常工作!=]

$("[id$='tab_TabContainer1_TabPanel2']").click(function(e) {
    var container = $find('TabContainer1');

    e.preventDefault(); //works for anything with preventDefault (e.g., not called from html onclick, etc.)

    $("[id$='Button1']").click();   //perform the button1 click event (which calls custom validation)

...
于 2012-12-13T16:59:08.070 回答