FoxInCloud
Conflict between Refresh() and wcHTMLgen
Me again ...
In a button, I had this code in refresh():
THIS.Visible = IIF (... .F.)
In wcHTMLgen(), I added:
toHTMLgen.cScriptJSadd(TEXTMERGE([jQuery('#<<THIS.wcID>>').attr('style', 'margin-left: 38%' ...
Both work well, but not together. Refresh is overwritten by toHTMLgen.cScriptJSadd ...
I added a "display: none" but I wanted to tell you
These 2 could conflict if they occurred concurrently, in fact they don't:
.wcHTMLgen()
executes once for all users, first time form is used (instantiated) by server
user state independent.Refresh()
execute each time form displays and each time your user event code calls it (such asthisForm.refresh
)
user state dependent
By the way, it's easier to manage CSS rules rather than altering CSS using JS:
procedure wcHTMLgen
lparameters toHTMlgen, tlInnerHTML
* toHTMLgen.cScriptJSadd(TEXTMERGE([jQuery('#<<THIS.wcID>>').attr('style', 'margin-left: 38%' ...
toHTMLgen.CSScustomAdd(TEXTMERGE([#<<THIS.wcID>> {margin-left: 38%; …}]))
The only exception is for .Visible
, if you can't set .Visible=.F.
in VFP at design time or in .Init()
: for reasons internal to jQuery, you need:
procedure wcHTMLgen
lparameters toHTMlgen, tlInnerHTML
toHTMLgen.cScriptJSadd(TEXTMERGE([jQuery('#<<THIS.wcID>>').hide()]))
by the way this code:
// this replaces the whole style attribute
toHTMLgen.cScriptJSadd(TEXTMERGE([jQuery('#<<THIS.wcID>>').attr('style', 'margin-left: 38%' ...
should be:
// this adds or replaces rules in the style attribute
toHTMLgen.cScriptJSadd(TEXTMERGE([jQuery('#<<THIS.wcID>>').css('margin-left: 38%; …')
Ok, thank you.
Is this correct in wcHTMLgen(): ?
IF THISFORM.wBSlHTMLgen
toHTMLgen.CSScustomAdd(TEXTMERGE([#<<THIS.wcID>> {width: 15%;}]))
ENDIF
because the instruction is not interpreted
it's perfect
you use this command in several other places in dooxi; make sure to always prefix ID with #
; eg.:
MODIFY CLASS labelvalid OF labelvalid.vcx method wcHTMLgen
LPARAMETERS toHTMLgen AS awHTMLgen OF awHTML.prg, tlInnerHTML && {en} doc in Parent Code {fr} doc dans le code parent
toHTMLgen.CSScustomAdd(TEXTMERGE("<<THIS.Label.wcId>> {" + "margin-left: -20px;}"))
toHTMLgen.CSScustomAdd(TEXTMERGE("<<THIS.Img.wcId>> {" + "color: #2ECC71; font-size: larger; margin-top: -2px;}"))
should be:
MODIFY CLASS labelvalid OF labelvalid.vcx method wcHTMLgen
LPARAMETERS toHTMLgen AS awHTMLgen OF awHTML.prg, tlInnerHTML && {en} doc in Parent Code {fr} doc dans le code parent
toHTMLgen.CSScustomAdd(TEXTMERGE("#<<THIS.Label.wcId>> {" + "margin-left: -20px;}"))
toHTMLgen.CSScustomAdd(TEXTMERGE("#<<THIS.Img.wcId>> {" + "color: #2ECC71; font-size: larger; margin-top: -2px;}"))