javascript - What's the best practice building unique component IDs using Catberry Framework? -


catberry has requirement components – ids must unique.

what's best practice building unique ids when have complicated hierarchy of nested components?

the recommended way building unique identifiers nested components is:

<parent-component­-id>:<child-component­-name>:<entity-­id>. 

entity-id optional , used in case have list of items or that.

it’s easy have id of component in render method using this.$context.attributes.id.

for example, have component renders list of items. name cat-list id some-list. nested components name cat-list-item have ids:

some-list:list-item:1 some-list:list-item:2 some-list:list-item:3 ... some-list:list-item:n 

if have more nested components cat-author each item have ids:

some-list:list-item:1:author some-list:list-item:2:author ... some-list:list-item:n:author 

so, if use rule have unique identifiers components on page.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -