0

Is it possible to have a dynamic field name in jsrender like this.

{{<cellcontent>}}

Common template as generic one. Cell content value is bound to a datasource. Is it possible?

BorisMoore
  • 8,444
  • 1
  • 16
  • 27
Sunil Prabakar
  • 442
  • 1
  • 5
  • 19
  • I changed the title to correspond to what I understand to be your intended question. Is that what you wanted to know, and did my answer below correspond? – BorisMoore Mar 24 '15 at 19:11

1 Answers1

0

Your question is not very clear, but if you are asking about using JsRender templates along with data-binding so that when the data changes the rendered result is automatically updated, dynamically, well yes, that is what JsViews is all about: http://www.jsviews.com/#jsviews. (JsViews is a data-binding layer on top of JsRender).

Here is a simple example:

var tmpl = $.templates("#myTemplate"),
    data = {name: "Jo"};

tmpl.link("#content", data);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//www.jsviews.com/download/jsviews.js"></script>

<script id="myTemplate" type="text/x-jsrender">
    {^{:name}} <br/>
    <input data-link="name trigger=true" />
</script>

<div id="content"></div>
BorisMoore
  • 8,444
  • 1
  • 16
  • 27