Accessing the target element from inside a Binding.converter RRS feed

  • Question

  • Hi, 

    I have a situation where I want to highlight a particular list item when it's bound property is equal to its inner text, so something like the following. 


    <div data-win-bind="style.border:Person.Name MyNamespace.nameHighlighter" >Bob</div>


    winJS.Namespace.define("MyNamespace" {
      nameHighlighter : function(personName) {
          var targetElement; // This is the part I can't get
          if( personName == targetElement.innerText){
              return "2px solid Red";
          else {
              return "1px dashed Black";

    So the problem I'm having is I can't get the target element that owns this bind from inside the converter. Is this possible? I have a long list of these person divs and I want them to automatically highlight themselves when the data changes.

    Sunday, November 18, 2012 6:13 AM


  • Hi,

    I think you can't write the code as follow:

    <div data-win-bind="style.border:Person.Name MyNamespace.nameHighlighter" >Bob</div>

    If you want to do the check, you may fire the function in onload() event.

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Marked as answer by Song Tian Friday, November 23, 2012 10:49 AM
    Monday, November 19, 2012 6:29 AM