util.js
18 lines
| 1 | import $ from 'jquery'; |
| 2 | |
| 3 | export default { |
| 4 | addField(fieldType, fieldCategory, collection, position) { |
| 5 | let footerModel = collection.findWhere({fieldType: "footer"}); |
| 6 | let instance = 'pp_form_builder_' + fieldCategory + '_fields'; |
| 7 | position = typeof position !== 'undefined' ? position : collection.indexOf(footerModel); |
| 8 | |
| 9 | const model = _.extend(window[instance][fieldType], {fieldType: fieldType}); |
| 10 | |
| 11 | collection.add(model, {at: position, sort: false}); |
| 12 | }, |
| 13 | |
| 14 | save_changes(collection) { |
| 15 | $('#pp-form-builder-fields-settings').val(JSON.stringify(collection.toJSON())); |
| 16 | $('.pp_edit_form form').trigger('submit'); |
| 17 | }, |
| 18 | } |