Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query in template css class name does not work in object usage only in object creation #114

Closed
milosPavic opened this issue Dec 28, 2021 · 1 comment

Comments

@milosPavic
Copy link

milosPavic commented Dec 28, 2021

Query in template css class name does not work in object usage only in object creation

<div class="{{this.isActive ? 'vv-lead-item active' : 'vv-lead-item'}}" data-id="{{this.id}}">

this.isActive:true/false is working on object creation

let item = new vvLeadItem(1,'peter','petersen',200,true); // works
     item.isActive=false; //not working
     item.name='Smith'// working ...
import { Slim } from './vendor/slim/index.js';
const tpl = `
<style>@import "../css/vv-lead-item.css"</style>
<div class="{{this.isActive ? 'vv-lead-item active' : 'vv-lead-item'}}" data-id="{{this.id}}">
 <span class="id">{{this.id}}<span *if="{{this.id != ''}}">.</span></span>
 <span class="name">{{this.name}}<span *if="{{this.name != ''}}">.</span></span>
 <span class="surname">{{this.surname}}</span>
 <span class="duration">{{this.duration}}</span>
</div>`;

export class vvLeadItem extends Slim {
    constructor(id,name,surname,duration,isActive=true) {
        super();
        this.id = id;
        this.name = name;//N.
        this.surname = surname;
        this.duration = duration;//"00:00:00";
        this.isActive=isActive;
    }
}

Slim.element('vv-lead-item', tpl, vvLeadItem);
@eavichay
Copy link
Member

eavichay commented Jan 5, 2022

When the element is created via the DOM the constructor receives no paramters. You might want to try this:

<vv-lead-item .active="{{whatever-defines-is-active}}"></vv-lead-item>

Web components do support using constructors, but it is not recommended if you intend to use templates.

Let me know how this works for you, I will be happy to assist.

@eavichay eavichay closed this as completed May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants