0

IE is the bane of my existence. Basically, I want to run validation from a button within the tab if the user tries to skip tabs- to prevent them from not filling in data and potentially breaking my database queries.

      $("[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;
    });

It should be that simple, and the above works in firefox/google chrome, but not IE8. IE8 simply just goes to the next tab after the validation, regardless of anything. Even if I return false; immediately, it just goes to the next tab. Honey Badger doesn't care, honey badger just goes to the next tab. Any ideas?

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 に答える