Ola
I'm trying to undertstand the mTarget variable on the custom view design specifically on the Remove sub.
When creating custom views, their HTML is appended to a target element. For example.
this mTarget is also a person of interest when adding to parent.
Now interestingly, there is a Remove sub where the same person of interest appears as mTarget.Empty , which is.
On the Remove sub, mTarget.Empty (removes all child nodes for the matched elements), meaning that the parent holder for mElement is cleared, this could include any other child element that I might not want to remove from mTarget.
I can remove mTarget.Empty as that is not the behavior I want when a child is removed, the parent should not be cleared. Am I understanding this right?
Thanks.
I'm trying to undertstand the mTarget variable on the custom view design specifically on the Remove sub.
When creating custom views, their HTML is appended to a target element. For example.
B4X:
mElement = mTarget.Append($"<${mTagName} id="${mName}" ${exattr}>${mText}</${mTagName}>"$).Get("#" & mName)
this mTarget is also a person of interest when adding to parent.
B4X:
'add component to parent
public Sub AddToParent(targetID As String)
mTarget = BANano.GetElement("#" & targetID.ToLowerCase)
DesignerCreateView(mTarget, Null)
End Sub
Now interestingly, there is a Remove sub where the same person of interest appears as mTarget.Empty , which is.
B4X:
'remove component
public Sub Remove()
mTarget.Empty
BANano.SetMeToNull
End Sub
On the Remove sub, mTarget.Empty (removes all child nodes for the matched elements), meaning that the parent holder for mElement is cleared, this could include any other child element that I might not want to remove from mTarget.
I can remove mTarget.Empty as that is not the behavior I want when a child is removed, the parent should not be cleared. Am I understanding this right?
Thanks.