【问题标题】:Display error in IE 9在 IE 9 中显示错误
【发布时间】:2012-06-15 21:31:50
【问题描述】:

我有一个即将推出的页面,位于 www.remindeals.com。

当单击“首先进入”按钮并提交电子邮件(做一个像 abc@abc.com 之类的假邮件)时,Modal 弹出窗口存在一个错误,其中背景不显示且仅显示社交图标悬停时出现。这是一个使用引导程序构建的 Rails 站点。

这个问题只出现在IE 9..有人有线索吗?

下面附上相关的jquery,不知道这是否有帮助。

$('document').ready(function() {

  // display validation errors for the "request invitation" form
  if ($('.alert-error').length > 0) {
    $("#request-invite").modal('toggle');
  }

  // use AJAX to submit the "request invitation" form
  $('#invitation_button').live('click', function() {
    var email = $('form #user_email').val();
    var password = $('form #user_password').val();
    var dataString = 'user[email]='+ email + '&user[password]=' + password;
    $.ajax({
      type: "POST",
      url: "/users",
      data: dataString,
      success: function(data) {
        $('#request-invite').html(data);
        loadSocial();
      }
    });
    return false;
  });

})

// load social sharing scripts if the page includes a Twitter "share" button
function loadSocial() {

    //Twitter
    if (typeof (twttr) != 'undefined') {
      twttr.widgets.load();
    } else {
      $.getScript('http://platform.twitter.com/widgets.js');
    }

    //Facebook
    if (typeof (FB) != 'undefined') {
      FB.init({ status: true, cookie: true, xfbml: true });
    } else {
      $.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
        FB.init({ status: true, cookie: true, xfbml: true });
      });
    }

    //Google+
    if (typeof (gapi) != 'undefined') {
      $(".g-plusone").each(function () {
        gapi.plusone.render($(this).get(0));
      });
    } else {
      $.getScript('https://apis.google.com/js/plusone.js');
    }
}

谢谢!

【问题讨论】:

  • 你不是说你实际遇到了什么问题?
  • IE9 有开发者工具,尝试单步执行你的代码。
  • @Pekka 添加了问题所在
  • @greg 不幸的是我不熟悉 IE9 工具。
  • @NKeating 只需按 F12 并转到控制台。它会告诉你错误在哪里

标签: jquery ruby-on-rails ruby-on-rails-3 twitter-bootstrap


【解决方案1】:
$('document').ready(function() { <-- Document isn't supposed to be in quotes

正确的方式是这样的

$(document).ready(function() { //code here });

【讨论】:

    【解决方案2】:

    在 IE 的输入字段中按 Enter 时,您的页面将提交到 thankyou.html,而不是打开带有社交统计信息的模式。这是因为在输入字段中按Enter 提交时,#invitation_buttonclick 事件不会被触发。

    将您的文本 inputsubmit 按钮包装在 &lt;form/&gt; 中,然后替换:

    $('#invitation_button').live('click', function() {
    

    与:

    $('form').live('submit', function() {
    

    或者,当您使用 jQuery 1.7.2 时:

    $('form').on('submit', function() {
    

    您也可以考虑使用 CDN 托管的 jQuery 副本,而不是将其托管在您的网站上,因为它为您的用户提供了更好的缓存和加载时间。

    您页面的其余部分似乎与我的 IE 中的 FF/Chrome 相同。

    【讨论】:

    • 感谢@fabricio .. 我相信您的修复在 IE 上有效,但副作用似乎是当电子邮件输入出现错误时(只需在电子邮件中输入字母“a”即可触发)格式被破坏了......有什么想法吗?
    猜你喜欢
    • 2016-01-04
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 2011-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多