简体   繁体   English

如何在Rails中不使用jquery_ujs的情况下使用jquery和javascript

[英]How to use jquery and javascript without jquery_ujs in rails

My code: 我的代码:

application.js application.js

//= require jquery
//= require jquery_ujs

index.html.erb index.html.erb

<%= link_to("test", {:controller => 'user', :action => 'create'} , :remote => true ) %>

create.js.erb create.js.erb

alert('click from crate.js.erb');

If I don't use //= require jquery_ujs and :remote=>true , i get an error. 如果我不使用//= require jquery_ujs:remote=>true ,则会出现错误。

How i use jquery without jquery_ujs and :remote true ? 我如何在没有jquery_ujs:remote true情况下使用jquery?

Rails 3: Using link_to :remote => true with jQuery UJS Rails 3:使用link_to:remote => true与jQuery UJS

The Rails Unobtrusive Javascript (UJS) library provides two main pieces of functionality: Rails入门Java(UJS)库提供了两个主要功能:

You can add add :remote => true to link_to and the link will be submitted via AJAX. 您可以在link_to中添加add :remote => true ,链接将通过AJAX提交。

You can add :remote => true to form_for and the form will be submitted via AJAX. 您可以在form_for中添加:remote => true ,该表单将通过AJAX提交。

there is no way to use this feature without the jQUJS of course you could do this by yourself - but better question yourself why you dont want to stick with ujs. 如果没有jQUJS,就无法使用此功能,当然您可以自己执行此操作-但最好问自己一个问题,为什么不想坚持使用ujs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jquery_ujs与Rails 4中的Kaminari AJAX冲突? - jquery_ujs conflicts with Kaminari AJAX in Rails 4? jquery_ujs 和 rails-ujs 问题 ajax 页面的问题 - probleme with jquery_ujs and rails-ujs problem ajax page jquery,带有jquery-ui-rails gem的jquery_ujs - jquery, jquery_ujs with jquery-ui-rails gem Rails,default.js 为空,未加载jquery 和jquery_ujs - Rails, default.js is empty, and jquery and jquery_ujs not loaded rails 3.2.9 jquery_ujs无法与link_to一起使用 - rails 3.2.9 jquery_ujs not working with link_to 在Rails 5.1中仍然需要`require jquery_ujs`吗? - Is `require jquery_ujs` still needed in Rails 5.1? 如何在jquery_ujs响应的Javascript ERB模板中调用Coffeescript模板? - How do I call Coffeescript templates in a Javascript ERB template in a jquery_ujs response? 如何在禁用的管道中包含“ jquery_ujs”,以便能够对表单使用“ remote:true”? - How to include “jquery_ujs” with disabled pipeline to be able to use “remote: true” for forms? rails 4,link_to在jquery时不使用destroy动作,需要jquery_ujs - rails 4, link_to not working with destroy action when jquery, jquery_ujs is required Rails 4:有谁遇到过jquery_ujs破坏了回调URL,从而中断了Ajax屏幕更新的情况? - Rails 4: Has anyone encountered jquery_ujs mangling callback url, which breaks ajax screen update?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM