re: Component-based web with zUIx.js VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Amazing library! But just a question, how can we prevent a component from loading in a certain context (a.k.a if it does not pass a javascript test)?
 

Don't put the data-ui-load attribute on the container, use data-ui-field to assign an identifier to it:

<div data-ui-field="my-container"></div>

and then load the component using js api

if (canLoad) {
  const el = zuix.field('my-container');
  zuix.load('my/component', {
    container: el
  });
}

if you also need to store a reference to the component once is loaded then you go like this

let myComponent;
if (canLoad) {
  const el = zuix.field('my-container');
  zuix.load('my/component', {
    container: el,
    ready: function() {
      // component ready!
      myComponent = this; 
    }
  });
}
 
code of conduct - report abuse