Fine control of HTML templates with AMCP

Is there a way to pass CSS template properties using standard UPDATE functionality? For instance to change font-size, or padding, etc dynamicly, using for example f5=[value] and pass that value to CSS of the template?.

I know custom JavaScript functions can be defined and called through INVOKE, but is there a way without using INVOKE?

not that hard

just make a if statement in the update function.
a bit of a rough/harsh example here

        function update(str){
            obj = JSON.parse(str);
            console.log(obj)
            Object.keys(obj).forEach(function(key) {
                    try{  
                        if (key === 'colorf0') {
                        	document.getElementById('f0').style.color = obj[key]
                        } else {
                        templateField= document.getElementById(key);
                        templateField.innerHTML=obj[key];                        }            
                    }
                    catch(err){
                        console.log(err);
                    }
            });
        };

off coarse this is quite a dirty fast way.
if you make a naming convention for your self you can offcoarse make a more proper / universal function to change all kind’s off styles

grt
Maurice

Thanks, nice idea, but this way property is hardwired by the key name, value left unused, and also mixing the JS code with CSS which can be tricky.

Anything else someone used?

hi itod

like i said a dirty solution. :rofl:
but if you make your self a naming convention like for instance
‘size#f0’, ‘color#f0’
you can easily make a function that test’s if the input is a text or a style input
without hardwiring
off coarse # is not the best seperator but i guess you get the idea

You can customize your JS thee best possible, it is the best solution yes :slight_smile: No other way to do it.
Or you can add a parameter that is interpreted by your JS to include a specific .css file where you have all your config , could work too.