jQuery UI Widgets Forums Angular enable and disable components

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 7 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • enable and disable components #91080

    holap
    Participant

    Hi, I’m trying to enable and disable components using [disabled]=”condition” in template. This works fine when condition is toggled true, but it doesn’t work when changed to false.

    example template html

    
    <jqxButton [disabled]='!enabled'>My button</jqxButton>
    <jqxButton (onClick)="toggle()" >Toggle</jqxButton>
    My button should be enabled: {{ enabled }}
    

    example ts

    
    import { Component, OnInit } from '@angular/core';
    import { jqxButtonComponent } from "../../libs/jqwidgets-ts/angular_jqxbuttons"
    
    @Component({
      selector: 'example',
      templateUrl: './example.component.html',
      styleUrls: ['./example.component.css']
    })
    export class ExampleComponent implements OnInit {
    
      constructor() { }
    
      enabled : boolean = true;
    
      ngOnInit() {
      }
    
      toggle() : void {
        this.enabled = !this.enabled;
      }
    
    }
    

    In the examle “My button” is enabled, then it becomes disabled when I press “toggle”. If I press “toggle” again I espect “My button” to be enabled again but it keep be disabled. What am I doing wrong?

    enable and disable components #91139

    Hristo
    Participant

    Hello holap,

    It is normal behavior, when you disable the Button once then cannot fire click event again.
    You could try with some other property.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.