// required all js files for FormilyEditor functionality // and initialization //= require formily/formily_editor //= require formily/editor/form_preview //= require formily/formily_modal $(document).ready(function(){ window.FormilyModal.initialize(); window.FormilyEditor.initialize(); $(document).trigger('formily_form_updated'); $(document).foundation(); $(document).on('formily_update_tr', function (e, data) { if(Object.keys(data).length == 0) { data = window.FormilyModal.data; } var table_id = data.model_id + '_' + data.user_id; var table = $('[data-formily-form-table=' + table_id + ']'); var tr = table.find('tr[data-formily-form-id=' + data.form_id + ']'); $.ajax({ url: '/formily/forms/reload_formily_table', type: 'POST', data: data, success: function(data){ if(tr.length > 0){ tr.replaceWith(data); } else { table.append(data); } } }); }); $(document).on('click', 'td button[data-formily-src]', function(){ window.location = $(this).data('formily-src'); }); });