javascript - 隔离导轨插件上的远程链接不起作用
问题描述
我在将远程链接添加到隔离的 Rails 插件时遇到问题。当我单击链接时,它什么也不做。我什至没有收到任何错误消息,它什么也没做。
这是链接:
<!-- app/views/my_plugin/models/new.html.erb -->
...
<fieldset id="attrs">
<legend><%= t 'my_plugin.attrs' %></legend>
<%= link_to t('my_plugin.new_attr'), models_add_attr_url, :remote => true %>
</fieldset>
...
这是我的路线:
# config/routes.rb
MyPlugin::Engine.routes.draw do
...
get 'models/add_attr'
end
这是我的控制器:
# app/controllers/my_plugin/models_controller.rb
require_dependency "my_plugin/application_controller"
module MyPlugin
class ModelsController < ApplicationController
...
# GET /models/add_attr
def add_attr
respond_to { |format| format.js }
end
...
end
end
这是我的js文件,只是一个测试:
// app/views/my_plugin/models/add_attr.js.erb
console.log('hello');
这是我的引擎:
# lib/my_plugin/engine.rb
module MyPlugin
class Engine < ::Rails::Engine
require 'jquery-rails'
require 'turbolinks'
isolate_namespace MyPlugin
end
end
这是我的宝石规格:
# my_plugin.gemspec
...
Gem::Specification.new do |spec|
...
spec.add_dependency "rails", "~> 5.2"
spec.add_dependency 'jquery-rails', '~> 4.3'
spec.add_dependency 'turbolinks', '~> 5.2'
...
end
我希望我提供了足够的信息。谢谢你的帮助。
解决方案
推荐阅读
- redux - Redux - 将 ownProps 参数传递给选择器
- ios - 将数据从 Tableview 传递到 CollectionView SWIFT
- ios - Objective-C:我想比较/排序块中的数组
- ios - AdMob EU Consent SDK iOS 错误:同意表单只能与自定义提供商选择一起使用
- keycloak - Keycloak 模板可用变量
- java - 如何在java中裁剪图像?
- jquery - 导出模块中未触发 jquery 更改事件
- c# - GeoCoordinateWatcher 如何获取位置 C#
- angular - 如何通过在Angular4中将localStorage值作为参数传递来调用API url
- c++ - 确定用户是否可以使用 c++ 提升进程