jQuery(function($) { "use strict"; // cache fields var FIELDS = DATA.site_dialogs.fields; $('#site-add-dialog').on('show.bs.modal', function() { $(this).trigger({ type: 'guff.loaded', site_data: FIELDS.text.reduce(function(r, id) { r[id] = FIELDS.defaults[id] || ''; return r; }, FIELDS.list.reduce(function(r, id) { r[id] = []; return r; }, {})), }); }); });