简体   繁体   English

Rails-重新加载JS和CSS

[英]Rails - Reload JS and CSS

I'm using Cocoon to dynamically add fields to my forms, when buttons are pressed. 按下按钮时,我正在使用Cocoon向表单中动态添加字段。

The problem is that I need to run part of my JS code to apply design changes. 问题是我需要运行部分JS代码才能应用设计更改。 I'm running the JS with Document Ready, however I only add those fields afterwards. 我正在使用文档就绪运行JS,但是之后我只添加这些字段。

$( document ).ready(function() {
   $('form.form').materialForm();
});

I'm using this simple material design framework, and I just need to run this: 我正在使用这个简单的材料设计框架,我只需要运行以下命令:

$('form.form').materialForm();

Ideas? 有想法吗?

EDIT: 编辑:

HAML code: HAML代码:

.container
.row
  .col-xs-1.col-xs-offset-2
    %span.step.step-small.step-secondary 3
  .col-xs-6
    = f.fields_for :list_impacts do |ia|
      = render "folder/folder1/impacts", f: ia
    .links
      = link_to_add_association 'add impacts', f, :list_impacts, partial: 'folder/folder1/impacts'

Use the callbacks . 使用回调 So something like 所以像

$('form.form').on('cocoon:before-insert', function(e, insertedItem) {
  $(insertedItem).materialForm();
});

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM