jQWidgets Forums

jQuery UI Widgets Forums Angular jqxValidatorComponent in Augular 2

This topic contains 2 replies, has 2 voices, and was last updated by  Ivo Zhulev 8 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • jqxValidatorComponent in Augular 2 #91595

    andrea
    Participant

    I have a problem with jqxValidatorComponent in Angular 2,
    from typescript the following call works fine also according to the example:
    this.myValidator.validate(document.getElementById(‘formUserDetail’));

    but I’m not able to use the onSuccess:
    this.myValidator.onSuccess(this.onSaveContinue)

    I receive an error “Cannot read property ‘username’ of undefined”

    The typescript method normally works, but not from onSuccess:

    user:any = new Object();
    onSaveContinue(): void
    {
    if (this.user.username==null) {
    ….
    }
    }

    Is there a way to make it work?
    Thanks
    Andrea

    jqxValidatorComponent in Augular 2 #91606

    andrea
    Participant

    After some investigation I found out that this seams to be a known issue in typescript, described here:

    typescript-class-method-this

    As described in the link a possible workaround is to change the method signature as follow:

    
    onSaveContinue = () => {
      if (this.user.username==null) {
         ….
      }
    }

    This works properly with onSuccess:
    this.myValidator.onSuccess(this.onSaveContinue);

    jqxValidatorComponent in Augular 2 #91613

    Ivo Zhulev
    Participant

    Hi andrea.p,

    Thanks for the information.

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.