ModalForm

The Modal Form allows to get simple access to the form in the modal body using the event system.

Methods #

getData

Returns: Object

Get key=value object of the modal form fields when the key is name of field and the value is value of field.

(function($K)
{
    $K.add('module', 'mymodule', {
        init: function(app, context)
        {
            this.app = app;

            // define service
            this.modal = app.modal;
        },
        onmessage: {
            modal: {
                closed: function(sender, $modal, $form)
                {
                    var data = $form.getData();
                }
            }
        },
        showModal: function()
        {
            this.modal.open({
                url: '/server-side/my-modal.html',
                title: 'My Modal'
            });
        }
    });
})(Kube);

setData

Arguments
data Object key=value form data

Set key=value object to the modal form when the key is name of field and the value is value of field.

(function($K)
{
    $K.add('module', 'mymodule', {
        init: function(app, context)
        {
            this.app = app;

            // define service
            this.modal = app.modal;
        },
        onmessage: {
            modal: {
                open: function(sender, $modal, $form)
                {
                    $form.setData({ fieldname: value });
                }
            }
        },
        showModal: function()
        {
            this.modal.open({
                url: '/server-side/my-modal.html',
                title: 'My Modal'
            });
        }
    });
})(Kube);

getItem

Arguments
name String name of the form field

Returns: Dom Boolean

Get the field of modal form by the name.

(function($K)
{
    $K.add('module', 'mymodule', {
        init: function(app, context)
        {
            this.app = app;

            // define service
            this.modal = app.modal;
        },
        onmessage: {
            modal: {
                opened: function(sender, $modal, $form)
                {
                    var $field = $form.getField('name');
                }
            }
        },
        showModal: function()
        {
            this.modal.open({
                url: '/server-side/my-modal.html',
                title: 'My Modal'
            });
        }
    });
})(Kube);