0

我正在尝试将 jsRender-template 放在标签内。
我需要它才能将类似的东西渲染onmouseoveronmouseout任何元素中。

测试代码:

内模板

<small {{for "Key_" + Key tmpl="tooltip_logic"/}}>shows key on hover</small>

部分模板

<script type="text/x-jsrender" id="tooltip-logic-template">
    onmouseover="$('#Key_{{:#data}}').show();" onmouseout="$('#Key_{{:#data}}').hide();"
</script>

渲染模板之前的javascript

$.templates({ 
    ...
    tooltip_logic: $('#tooltip-logic-template').html() 
});

不过,输出会在标签 呈现。<small>

有什么办法可以做到这一点?如果没有,最接近的方法是什么?

4

1 回答 1

0

There are a couple of sample pages on jsviews.com that look at this scenario.

First, this "From rendering to linking" page shows how you can indeed use JsRender tags within the HTML markup of an element. It then goes from there towards how you can do the same thing in the context of JsViews and data-linking.

Later in the tutorial, on the page: "Using data-link and visibility, with mouse events (hover)", it explores alternative ways hook up the onmouseover behavior and showing/hiding a related HTML element.

于 2013-10-09T05:19:20.930 回答