Accediendo a 'this' en reacciona al asignar el método a un evento
Disculpe de antemano, soy muy nuevo en React.
EnprintDocument
Estoy configurando eloHiddFrame.onload = this.setPrint;
incluso athis.setPrint
pero recibo un error deCannot set property '__container__' of undefined
parathis
ensetPrint
en la primera tarea.
Estoy configurandoonClick={this.printDocument.bind(null, this.props.document.view_href)}
en el botón en render (). ¿Cómo asocio "esto" al evento real al que lo estoy asignando?
Aprecio mucho cualquier ayuda o consejo.
closePrint: function () {
document.body.removeChild(this.oHiddFrame.__container__);
},
setPrint: function () {
this.contentWindow.__container__ = this;
this.contentWindow.onbeforeunload = this.closePrint;
this.contentWindow.onafterprint = this.closePrint;
this.contentWindow.focus();
this.contentWindow.print();
},
printDocument: function (url) {
var oHiddFrame = document.createElement("iframe");
oHiddFrame.onload = this.setPrint;
oHiddFrame.style.visibility = "hidden";
oHiddFrame.style.position = "fixed";
oHiddFrame.style.right = "0";
oHiddFrame.style.bottom = "0";
oHiddFrame.src = url;
document.body.appendChild(oHiddFrame);
},