mercredi 24 août 2016

Ember.js Component didRender Variable Scope

I am using an Ember Component's didRender() hook to implement some javascript that needs to run after the DOM is loaded. For Example:

didRender() {
  var signaturePad = new SignaturePad($("#sigElement"));
  signaturePad.clear();
}

This is working fine. However, I need to access the signaturePad variable from my actions in the same component to have buttons function appropriately. Such as:

actions: {
   clearSignature: function() {
     signaturePad.clear();
   }
}

Unfortunately, it seems my variable defined in the didRender() hook for the component does not pass to the actions.

How am I able to access this variable from my actions within the same component?




Aucun commentaire:

Enregistrer un commentaire