====
view
====

.. js:function:: view(container)

**domain**: client 

**language**: javascript

**class** :doc:`Item class </refs/client/item_api>`

Description
===========

Use ``view`` method to create a view form of the item.

The method check if the javascript modules of the item and its owner are loaded,
and if not (the **Dynamic JS modules loading** 
:doc:`parameter of the project </admin/project/parameters>`
is set) then loads them.

If ``container`` parameter (Jquery object of the DOM element) is specified the
view form html template is inserted in the container.

If the :doc:`init_tabs </refs/client/task/m_init_tabs>` method of the task is 
called for this conainer the tab is created for this form.

After that it calls the
:doc:`create_view_form <m_create_view_form>`
method

Example
=======

In the following code the view for of the **Tasks** journal is created in the
on_page_loaded event handler:

.. code-block:: js

    function on_page_loaded(task) {
    
        $("#title").html(task.item_caption);
        if (task.safe_mode) {
            $("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);
            $('#log-out')
            .show()
            .click(function(e) {
                e.preventDefault();
                task.logout();
            });
        }
    
        task.init_tabs($("#content"));
        task.tasks.view($("#content"));
        
        $(window).on('resize', function() {
            resize(task);
        });
    } 

See also
========

:doc:`Forms </programming/interface/forms>`

:doc:`view_form <at_view_form>`

:doc:`view_options <at_view_options>`

:doc:`create_view_form <m_create_view_form>`

:doc:`close_view_form <m_close_view_form>`


