0

私が使用しているjquery-uiモーダルコードは次のとおりです。

//jQuery form dialog modal popup and submit
$(function() {
$("#facilitiesForm").validate();

$("#facilityForm").dialog({
    autoOpen: false,
    height: 470,
    width: 650,
    modal: true,
    buttons: {
       "Send To The Facilities Manager": function() {
            $("#facilitiesForm").submit();
        },
        "Cancel": function() {
            $( this ).dialog( "close" );
        },
    },
    close: function() {
        allFields.val( "" ).removeClass( "ui-state-error" );
    }
});

$("#helpForm").validate();

$("#helpdeskForm").dialog({
    autoOpen: false,
    height: 570,
    width: 650,
    modal: true,
    buttons: {
       "Send To The Helpdesk": function() {
            $("#helpForm").submit();
        },
        "Cancel": function() {
            $( this ).dialog( "close" );
        },
    },
    close: function() {
        allFields.val( "" ).removeClass( "ui-state-error" );
    }
});

$("#adminForm").validate();

$("#adminTasksForm").dialog({
    autoOpen: false,
    height: 470,
    width: 650,
    modal: true,
    buttons: {
       "Send To The Admin": function() {
            $("#adminForm").submit();
        },
        "Cancel": function() {
            $( this ).dialog( "close" );
        },
    },
    close: function() {
        allFields.val( "" ).removeClass( "ui-state-error" );
    }
});

$("#contactFacilityManager")
    //.button()
    .click(function() {
        $( "#facilityForm" ).dialog( "open" );
    });

$("#contactHelpdesk")
    //.button()
    .click(function() {
        $( "#helpdeskForm" ).dialog( "open" );
    });

$("#contactAdminTasks")
    //.button()
    .click(function() {
        $( "#adminTasksForm" ).dialog( "open" );
    });

});

バグに気付き始めたばかりで、IE でポップアップ ボックスが機能しません。私が得るエラーは次のとおりです。

Webpage error details

Message: Expected identifier, string or number
Line: 16
Char: 6
Code: 0
URI: http://newintranet/js/script.js

これが IE で動作しない理由 (Chrome と FF で正常に動作する) のアイデアはありますか?

4

2 に答える 2

4

buttons16 行目の「キャンセル」関数の右中括弧とオブジェクトの右中括弧の間に余分なコンマがあります。

実際には、36 行目と 56 行目で同じ間違いを 2 回繰り返しています。毎回、ダイアログのボタンを指定する最後です。

IE はこれを構文エラーと見なしますが、他のブラウザーはより寛容です (結局のところ、カンマの後の空のステートメントは何の効果もありません)。

于 2012-06-01T15:49:23.497 に答える
4

IE では、以下のコードで構文エラーがスローされているためです。余分なコンマを削除すると正常に動作します。

buttons: {
       "Send To The Helpdesk": function() {
            $("#helpForm").submit();
        },
        "Cancel": function() {
            $( this ).dialog( "close" );
        }, //extra comma here
    }
于 2012-06-01T15:49:46.757 に答える