Search code examples
jqueryjsrender

How to get the current object in for loop in JsRender


I want the current object which is set as value to checkbox in for loop of JsRender. Below is my code.

{{for data.UserConnection}}
  <li>
    <input name="checkboxlist" class="profilechkbox" type="checkbox" value={{:#view}} /><br />
    <a onclick="stateManager.renderSelectedProfileForInviteGroup({{:#index}})" title="{{:Fullname}}" class="active" href="#" >
      <img  src="{{:userDetails.ImagePath}}" width="40" height="40" /><br />
      {{:Fullname}}
    </a>
  </li>
{{/for}}

I set the value as {{:#view}} to get the current object. But I am getting [object object]. Please correct me if I am doing wrong here.


Solution

  • #view in JsRender is the current data object.

    By writing {{:#view}} you are trying to display the object, which would appear as [object Object] in the browser.

    Try {{:#view.data.yourattribute}}.