JQuery-ui对话框按钮在IE11中不执行任何操作

时间:2016-05-17 20:39:43

标签: javascript jquery html internet-explorer jquery-ui-dialog

我有一个像这样的HTML表单:

<div id="dialogGlobal" title="About You">     
  <form>
    <fieldset style="border: none;">
      <ul style="list-style-type: none; padding-left: 0px">
        <li><label for="username">Please Enter Your First Name</label></li>
        <li><input type="text" name="username" id="username" placeholder="Enter your name" pattern="[A-Za-z]{3,}" title="Your first name must be at least 3 letters" class="text ui-widget-content ui-corner-all" required></li>
        <li><label for="zipcode">Please Enter Your Zipcode</label></li>
        <li><input type="text" name="zipcode" maxlength="5" pattern="[0-9]{5}" id="zipcode" title="Please enter a 5 digit zip-code" placeholder="02134" class="text ui-widget-content ui-corner-all" required></li>
      </ul>
    </fieldset>
  </form>
</div>

和相应的JQuery-ui javascript

    dialogGlobal = $( "#dialogGlobal" ).dialog({
          autoOpen: false,
          height: 300,
          width: 350,
          modal: true,
        position: {
            my: "center center",
            at: "center center",
            of: "#map"
          },
      buttons: [{
        text: "Submit",
          click: function() {
            if(checkValues();){
               dialogGlobal.dialog("close");
            }
            else{
               alert("Invalid input");
            }
            }
        },
        id: "globalAccept"
      }],
      close: function() {

      },
        //Hack to avoid "ENTER" leading to a new page...
        open: function(){
            $("#dialogGlobal").keydown(function(e) {
              if (e.keyCode == $.ui.keyCode.ENTER) {
                $("#globalAccept").trigger("click");
              }    
            });

        }
    });

当我点击FF和Chrome中的“提交”时,一切正常。在IE 11中(在Surface RT上),没有任何反应,我甚至添加了一个警报,指示按钮被点击但没有弹出。我尝试添加$("#dialogGlobal").on("click",function(){dothesamething});但仍然没有,即使其他具有该侦听器的对象表现正常....

1 个答案:

答案 0 :(得分:-1)

IE可能处于兼容模式。要禁用兼容模式,请添加

到你的html标题