Hi all,
I want to move the VFP textbox.interactivechange () surface event from the server to the client.
*!* TextBox object
*!* --------------
*!*PROCEDURE INIT
*!* =THIS.ADDPROPERTY('champsaisi', .F.)
*!* RETURN DODEFAULT()
*!*ENDPROC
PROCEDURE INTERACTIVECHANGE
LPARAMETERS Useless_Parm
IF (TYPE('m.THISFORM.wlHTMLgen') == 'L' AND m.THISFORM.wlHTMLgen = .T.)
LOCAL lcJS AS STRING
TEXT to lcJS textmerge noshow flags 1 pretext 7
var cmd = jQuery('#<<this.wcID>>');
cmd.prop('champsaisie', true);
ENDTEXT
RETURN m.lcJS
ENDIF
WITH m.THIS
.champsaisi = .T.
ENDWITH
ENDPROC
Is this code the correct one to move the processing to the server side in the client's browser ?
Cordialement
Gilles
Hello Gilles,
I don't understand what you want to do but adding your property seems insufficient to me.
What exactly do you want to achieve ?
Bien à toi,
Vincent
Hi Gilles,
2 remarks
- to store an information into an HTML element Object Model, rather than adding a custom property to the element itself, you'd now add a property to the 'data' collection, now a standard for such a custom extension:
jQuery('selector').data('property', value)
- I understand that 'champsaisie' is a state property in your application; if you change it on client side, you should also change it on server side so that both are in sync. If you need this functionality in many places, we could maybe implement this method:
awFrm.wStatePropSet()
that would alter the same property on client and server, in the latter case by shunting (short-circuiting) the full state management process (restore, save, compare, … etc.).
Hi Thierry, In desktop mode, I use in the textbox, editbox, etc. objects the boolean champaisi property (and another string property champwhen). They are used to identify if there has been a keystroke of a text. This property is tested in the valid () event to trigger or not an action. This makes it possible to distinguish after typing on the 'enter' or 'tabulation' keys whether or not there has been a modification of the content of the input field. On the events:
- object.gotfocus () champaisi = .F.
- object.when () champwhen = object.value
- object.interactivechange champaisi = .T. Without the object.valid () event
IF m.THIS.champsaisi = .T. AND m.THIS.VALUE <> m.THIS.CHAMPWHEN
* here entry validation processing
ENDIF
In WEB mode I would like that champwhen and champaisi are only known and processed on the client side and on the client side that a 'blur' is sent to the server only if champaisi = .T. and value <> champwhen If there's another way, I'm a taker
Amicalement Gilles
As a standard behavior, in FoxinCloud.js
, for <input>
and <textarea>
:
FoxinCloud.inputsSetup()
sets a handler on.focus()
that stores.value
in.valueOld
FoxinCloud.EventRequest()
send the.blur()
event to the server only if.value !== .valueOld
, except if you set inxxx.js
:FoxinCloud.inputAlwaysBlur = true
orFoxinCloud.inputAlwaysBlurOnReturn = true
and user has hit theEnter
key.
Playing with FoxinCloud.inputAlwaysBlur
and/or FoxinCloud.inputAlwaysBlurOnReturn
may address your issue.
In this case you would set in xxx*.init()
: this.champSaisie = type('thisForm.wlWeb') == 'L' and thisForm.wlWeb