【问题标题】:does Ruby on Rails have a way to use jQuery rather than Prototype under-the-bonnet for its ajax view helpers? (e.g. "link_to_remote")Ruby on Rails 是否有办法在其 ajax 视图助手中使用 jQuery 而不是 Prototype? (例如“link_to_remote”)
【发布时间】:2010-02-24 23:03:55
【问题描述】:

Ruby on Rails 是否有办法在其 ajax 视图助手中使用 jQuery 而不是 Prototype? (例如“link_to_remote”)

【问题讨论】:

    标签: jquery ruby-on-rails


    【解决方案1】:

    jRails 适用于 Rails 2,覆盖各种功能以完成工作。但是,Rails 3 允许您完全用同等优先级的a jQuery driver 替换 Prototype 驱动程序。

    如果您还没有开始该项目,您可能需要考虑使用 Rails 3,因为该解决方案更加完整。也就是说,如果您需要的其他插件兼容 - 请参阅 RailsPlugins.org

    【讨论】:

    • 哪一个?轨道?我已经很好地使用了它,而且它在 Rails 社区中相对知名。无法与 Rails 3 系统匹敌,但在此之前它仍然表现出色。
    • Rails 3 非常可靠。缺少的只是 gem,插件支持,正在积极开发中。
    【解决方案2】:

    在 Rails 2.x 中,您可能对 jRails 感兴趣:http://github.com/aaronchi/jrails

    【讨论】:

      【解决方案3】:

      在 Rails 2 中,我对 jrails 没有运气(此时似乎已放弃)。我确实得到了link_to_remote 在 JavaScript 中使用这个 Prototype-to-Jquery 翻译:

      // Doing the Prototypey things with jQuery instead.
      window.Ajax = {
        Updater: function (update_id, request_uri, settings) {
          $.ajax({
            url: request_uri + "?" + settings.parameters,
            dataType: "html",
            timeout: 5000,
            async: settings.asynchronous,
            error: function() {
              console.warn("Error talking to server.");
            },
            success: function(data) {
              $("#"+update_id).html(data);
            }
          });
        }
      };
      

      (如果你走这条路,你需要为你使用的任何其他助手提供类似的翻译。)

      【讨论】:

        猜你喜欢
        • 2011-07-13
        • 2011-01-08
        • 2011-06-27
        • 2013-03-18
        • 2015-03-03
        • 2011-03-30
        • 1970-01-01
        • 1970-01-01
        • 2011-06-21
        相关资源
        最近更新 更多