# weforms/1.4.3/assets/components/template-modal/index.js

weForms – Easy Drag &amp; Drop Contact Form Builder For WordPress, version 1.4.3. 60 lines.

- Page: https://pluginprobe.com/plugins/weforms/1.4.3/code/assets/components/template-modal/index.js
- Raw: https://pluginprobe.com/plugins/weforms/1.4.3/raw/assets/components/template-modal/index.js
- Modified: 2019-11-18T04:29:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/weforms/1.4.3/code/assets/components/template-modal/index.js#L10-L20`.

```javascript
Vue.component('wpuf-template-modal', {
    template: '#tmpl-wpuf-template-modal',

    props: {
        show: Boolean,
        onClose: Function,
    },

    data: function() {
        return {
            loading: false,
            category: 'all',
        };
    },

    methods: {

        blankForm: function(target) {
            this.createForm( 'blank', target );
        },

        createForm: function(form, target) {
            var self = this;

            // already on a request?
            if ( self.loading ) {
                return;
            }

            self.loading = true;

            $(target).addClass('updating-message');

            wp.ajax.send( 'weforms_contact_form_template', {
                data: {
                    template: form,
                    _wpnonce: weForms.nonce
                },

                success: function(response) {
                    self.$router.push({
                        name: 'edit',
                        params: { id: response.id }
                    });
                },

                error: function(error) {

                },

                complete: function() {
                    self.loading = false;

                    $(target).removeClass('updating-message');
                }
            });
        }
    }
});

```
