Skip to content

Commit

Permalink
Fix component loading with Turbolinks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Roccoberton committed Mar 14, 2021
1 parent d7c4fe6 commit c096b1f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/assets/javascripts/activeadmin/dynamic_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@
}
}

// Init
$(document).ready(function () {
function dfInit() {
// Setup dynamic fields
const selectors = '.active_admin .input [data-if], .active_admin .input [data-eq], .active_admin .input [data-not], .active_admin .input [data-match], .active_admin .input [data-mismatch], .active_admin .input [data-function]'
$(selectors).each(function () {
Expand Down Expand Up @@ -249,5 +248,8 @@
$('[data-field][data-field-type="select"][data-save-url]').each(function () {
$(this).on('change', $.proxy(dfUpdateField, $(this)))
})
})
}

$(document).ready(dfInit)
$(document).on('turbolinks:load', dfInit)
})()

0 comments on commit c096b1f

Please sign in to comment.