Webanizr Logo
Open / sluit menu
Webanizr javascript modules
Webanizr javascript modules

Webanizr javascript modules enables you to simply add functionality to your website, regardless of the platform you use.

Loading the code

To load the core code, add the following tag to the head of the html of your website:

<script src="https://cdn.cpmodules.webanizr.com/cp/1.0.1/cp.js"></script>

Where 1.0.1 can be replaced with the most up-to-date version of the Webanizr javascript modules core.

Setting versions for the modules you want to use

Before you can use the javascript modules, you need to state which version you want to use. You can add the following code to a script tag in the head of the html under the line where you load the core:

cp.setModules({
    'callApi'  : '1.0.1',
    'buildForm' : '1.0.1',
    'formValues' : '1.0.2'
});

Where the key of the name of the module you want to use, and the value the version number for this module.

Adding functionality

Now the core and modules are set, you can start adding functionality to your website. You define the functionality as a callback function in cp.run:

cp.run(() => {
    // your code here
});

Combining it all together (example)

In this example we load the structure of a form from a url and display the form in a div with the id "demo-form":

<script src="https://cdn.cpmodules.webanizr.com/cp/1.0.1/cp.js"></script>
<script type="text/javascript">

    // set versions
    cp.setModules({
        'callApi'  : '1.0.1',
        'buildForm' : '1.0.1'
    });

    // run code
    cp.run(() => {
        
        // display a demo form 
        cp.collect('callApi', { url__api : 'https://myowndomain.com/models/model-for-demo-form.json' }, (data) => {
            cp.send('buildForm', data, { id__dom : 'demo-form', id__form : 'mydemo' }, (data) => {
            
            // code to be run after the form is displayed on the page
            });
        });
    }
</script>

List of modules

Now you know how to get started, it's time to dive into all the available modules to find the functionality you are looking for:

>> Next: all modules