Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

How to write a new view component?

1001 Binary edited this page Jun 11, 2019 · 2 revisions

Basically, each view in ZuckerJS represents as user interface. It often contains two main files:

  • [VIEW].htm: contains HTML code.
  • [VIEW_META].js: contains view meta information about component.

Create a Hello World view component:

File hello-world.view.htm:

<h3>Hello World</h3>

File hello-world.view.js:

(function (win) {
    return {
        name: 'hello-world.view',
        version: 'v1.0.0',
        templateName: '',
        route: '/',
        isDefault: true,
        type: 'view',
        get: function (callback) {
            win.zucker.utils.getView('hello-world.view.htm', function (data) {
                callback(data);
            });
        }
    };
})(window);

Add it to ZuckerJS configuration

window.zucker.config(['hello-world.view']).execute();

Meta Information

  • name: component name.
  • version: component version.
  • templateName: inherit template component.
  • route: hash and specify what request from user.
  • isDefault: default view.
  • type: component type.
  • get: this function is to get view content from server.