I have a text box where I am setting the value in javascript when a done button is pressed. The value shows up in the textbox but does not fire the text changed event on the textbox control. It will fire if I select the text box after the value is set but I want it to happen as soon as it is set.. How would I get this to fire after the value is set?
Thanks, – Tim Larson
Hi Tim,
When the third party widget calls back your event handler the context (this) in javascript is usually lost and “this” ends up referring to window. Wisej (qooxdoo) widgets always call their callbacks preserving the context.
In your sample and fix the problem is that when you are in SigImageCallback() “this” is already lost. If you assign “var me = this” in there it’s too late. There are 2 solutions:
Solution 1: Do not use the function, use a closure
var me = this;
GetSigImageB64(function(){
// here me is preserved.
});
Solution 2: Bind the callback function to the context.
GetSigImageB64(SigImageCallback.bind(this));
The call to bind() is a javascript feature that builds a function bound to the context passed in bind. The code above works as long as “this” is the Wisej widget.
HTH
Best,
Luca
Hi Tim,
try to store a reference to this before the callback:
var me = this;
and use me instead of this after the callback.
Hope that helps.
Best regards
Frank
Sorry to be a pain but I am getting so frustrated right now trying to get this last part done.
When the following is run from the code I posted earlier it calls the SigImageCallback but when in this callback I can not call this.fireWidgetEvent(“myeventname”, “Hello”) It says it is not part of the class.
GetSigImageB64(SigImageCallback);
Any help would be greatly appreciated.
Tim Larson
Hi Tim,
you can use the same technique we used in the last eSignature sample code:
.fctbNone{ color:#000000; } .fctbStyle0{ color:#2e75b6; } .fctbStyle1{ color:#a31515; } change: function(e) { me.fireWidgetEvent("change", {lastImage: e.lastImage}); }
You can send any data back to the Wisej.web.widget on the server using this.firewidgetEvent (“myeventname”, data), i.e.
this.fireWidgetEvent(“myeventname”, “Hello”) or
this.fireWidgetEvent(“myeventname”, {text:’hello’, count:12, ‘base64:here38jd232d2’});
The Wisej.web.widget will then fire WidgetEvent. The data is available in e.Data as a dynamic object
or the actual simple value, i.e. string name = e.Data or string name = e.Data.text.
Best regards
Frank
I have a widget for a signature pad from Topaz Systems. What I want to do is return the sigImageCallback value to the server. Right now I created the server side text box and it populates the value. Is there a way I can get the string of the image passed back to the server so I can save it to the database? I thought I may have to do an onchange event on the container but it didn’t work.
this.init = function() {
// your initialization code.
var me = this;
this.container.innerHTML =<canvas id=’cnv’ name=’cnv’ width=’304‘ height=’99‘></canvas>
}
this.onSign = function(){
var ctx = document.getElementById(‘cnv’).getContext(‘2d’);
SetDisplayXSize( this.getWidth() + “px” );
SetDisplayYSize( this.getHeight() + “px” );
SetTabletState(0, tmr);
SetJustifyMode(0);
ClearTablet();
SetKeyString(“0000000000000000”);
SetEncryptionMode(0);
if(tmr == null)
{
tmr = SetTabletState(1, ctx, 50);
}
else
{
SetTabletState(0, tmr);
tmr = null;
tmr = SetTabletState(1, ctx, 50);
}
}
this.onDone = function(){
if(NumberOfTabletPoints() == 0)
{
alert(“Please sign before continuing”);
}
else
{
SetTabletState(0, tmr);
//RETURN TOPAZ-FORMAT SIGSTRING
SetSigCompressionMode(1);
//document.FORM1.bioSigData.value=GetSigString();
//$(“#sigStringData).text += GetSigString();
//this returns the signature in Topaz’s own format, with biometric information
//RETURN BMP BYTE ARRAY CONVERTED TO BASE64 STRING
SetImageXSize(275);
SetImageYSize(60);
SetImagePenWidth(5);
GetSigImageB64(SigImageCallback);
}
}
function SigImageCallback( str )
{
var txt1 = document.getElementsByName(‘sigStringData’)[0];
txt1.value = str;
}
Hi Tim,
can you please share some more details on how you are setting the textbox value ?
If you set it directly on the DOM element, it won´t fire. If you use the API like
this.setValue (“hello”)
or
this.textBox1.setValue (“hello”)
it will fire.
Hope that helps.
Best regards
Frank
Please login first to submit.