问题标签 [jquery-rails]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - 如何修复rails中的jquery-ui rails自动完成错误(turbolinks:load)
我正在研究rails中的自动完成部分。我正在使用'jquery-ui-rails' gem。虽然使用$(document).ready
它正在工作,但$( document ).on('turbolinks:load', function() {}
由于物化链轮,我使用它不工作。
如果我在 application.js 中删除 //= require materialize-sprockets 那么它就可以工作了。如果我添加该行,则它不起作用。我需要物化链轮用于设计目的。
宝石文件
应用程序.js
_form.html.erb
类别控制器.rb
产品.js
路线.rb
如何使用 $( document ).on('turbolinks:load') 和 //= require materialize-sprockets ?
jquery - jQuery conflict on Rails
My application.js
:
My Gemfile
:
If I I just leave my app like that, all my jQuery will work fine. But I also need
on my application.html.erb
since I am using Bootstrap 4.
So with this configuration, I am experiencing lot of issues with my jQuery, like
$(...).flatpickr is not a function
Is there a way to avoid those conflicts? I suppose that's because I'm including multiple jQueries on my app.
If I remove //= require jquery
all the Bootstrap-related jQuery will work, but my custom scripts won't.
If I remove <script src="https://code.jquery.com/jquery-3.3.1.min.js"</script>
my scripts will work but all Bootstrap-related won't (like the hamburger navbar or similars).
ruby-on-rails - 在新选项卡中打开时,带有 `method` 参数的 Rails `link_to` 会给出 404
使用 Ruby 2.5.1/Rails 5.2.4.1 我生成了一个新的 Rails 应用程序,并编辑/创建了以下文件:
如果我正常单击此链接,它会发出 POST 请求并按预期给出成功响应(204)。
如果我单击以在新选项卡中打开它(中间单击/右键单击和“在新选项卡中打开链接”),它会发出 GET 请求并给出 404/RoutingError。
这种不同的行为取决于我如何打开(默认情况下对用户显示的内容)一个正常链接似乎令人惊讶 - 这是预期的行为吗?我猜这与使用 Rails UJS 的链接有关,并且在打开新选项卡时表现不同?在 Rails 中获取(看起来像)一个生成 POST 的链接的最佳方式是什么,无论它是如何打开的?
jquery-ui - Rails 5.0 和 JQuery .dialog() 不工作
我正在将 rails 应用程序从 升级4.2
到5.0
. 红宝石版本是2.6.4
该应用程序有一个视图,允许用户单击链接以运行调度脚本,将学生分配到课程/班级。该脚本可能需要几分钟才能完成,因此我们会显示一个模式对话框,就像进度条一样,显示进程当前所在的位置。但在rails 5.0
版本中,这不起作用。没有错误,只是没有出现弹出窗口。我认为这是 JQuery 的事情,所以使用 try/catch 块,我发现它在.dialog(...)
调用中。但我不确定它为什么会失败。我相信我JQuery
为 rails 5.0 正确设置了正确的 gem 和资产/文件。
弹出窗体:
我已经阅读了位于:ruby-docs 的文档。我看到我只需要使用//= require jquery-ui
来要求所有内容,但我添加了//= require jquery-ui/widgets/dialog
只是为了确定。
我缺少什么让这个工作?
感谢您的任何建议。
javascript - 单个 `remote: true` 表单标签不会在我的 rails 应用程序中生成类型为 `js` 的请求
基本上我无法获得remote: true
作为 xhr 请求提交的表单。
html.erb
自从我使用基于和js.erb
基础的前端以来已经有很长时间了,所以我可能在这里做一些愚蠢的事情
使用 Ruby 2.5.7 和 rails 4.2.11,我正在使用gem 'jquery-rails'
.
我的application.js
包含:
我们的应用程序中有许多表单form_tag
用于remote: true
发出 ajax 请求,但特定的表单不起作用。它发送带有标头的请求,Content-Type text/html
然后抛出错误,因为它找不到相应的模板,因为它不是在寻找带有js.erb
后缀的东西
生成表单的 html 是:
并且呈现的html是
我已经验证了 jQuery$
在这种情况下是可用的。具体错误是:ActionView::MissingTemplate - Missing template order_items/create_waitlist_line_item, application/create_waitlist_line_item with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}. Searched in:
这似乎表明它正在根据请求标头寻找错误的格式。
关于这里可能出了什么问题或者我如何更聪明地调试它的任何想法?还有其他方法可以强制它作为 js 请求提交吗?我在这上面花了很多时间。