Quote:
Originally Posted by Dormilich
ah, that seems even easier…
- // using some pseudo code
- element.onclick = function()
-
{
-
// reset all elements to default
-
var list = getElements(…);
-
foreach (list) { this.style.border = "thin solid black"; }
-
// change current element
-
this.style.border = "thick solid black";
-
}
With that solution, if you have other elements that have formatting - then that formatting will be wiped out. Also - if I have many of these behaviors - then it'll be scanning all the elements on the page for a single operation .. that'll slow things down considerably.
I could solve this very easily by putting in
-
<input type="hidden" id="lastUpdatedElement" value="">
-
Then having the HTC reference lastUpdatedElement.value and retreive/store the highlighted cell.
The problem is I want to make this self-contained without any extra code required in the parent page. Generic, Reuseable programming.
The only ways I can see that you can achieve this is:
a) Having a Static variable declaration in the HTC. A variable that is shared between all instances of the HTC behavior.
b) Having the HTC create a property or attribute within the parent DOM ... like a registry key .. and all HTCs reference that.
Just thought of something - I could have the HTC inject a hidden input tag into the parent document .. The HTC would need to check to see if the element exists in the parent - and if not, do a createElement().
I'm wondering if there is an even better option out there...