簡體   English   中英

Rails nested_form對文檔的懷疑

[英]Rails nested_form doubts on documentation

嗨,我在rails應用程序上使用gem“ nested_form”。實際上,當我在Documentation中找到它時,我感到非常高興:

Enhanced jQuery JavaScript template

You can override default behavior of inserting new subforms into your form. For example:

    window.nestedFormEvents.insertFields = function(content, assoc, link) {
      return $(link).closest('form').find(assoc + '_fields').append($(content));
    }

我需要這樣做,所以我去了application.js,我在那看到了require jquery_nested_form ..所以我去了“ vendor / assets / javascript”,我想我會在那找到文件,但是沒有!我找不到文件

jquery_nested_form.js

我需要找到它進行編輯,對嗎? 還是我錯過了一種更簡單的方法?

另外,如果我只是想“覆蓋表單的1個ID中的默認行為”而不是在所有字段中都沒有,文檔在這里http://rubydoc.info/gems/nested_form/0.3.2/frames

但是我不知道該怎么做。

您不必編輯javscript文件。

按照嵌套形式進行操作

如果您需要覆蓋任何行為,只需在application.js文件中添加新的javscript代碼

如果仍然需要對其進行編輯:

如果您不使用資產管道,請運行此生成器來創建JavaScript文件。

rails g nested_form:install

然后,您可以在布局中包括生成的JavaScript。

<%= javascript_include_tag :defaults, "nested_form" %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM