问题描述
我具有分页功能,因为在模板中执行此操作有些棘手.问题是,如果我这样放置它:
{{ paging( rows, limit, offset ) }}
它显然将转义输出,因此我尝试了三重步法,并且输出符合预期.但是然后,它不再检测到on-click
事件了..有什么建议吗?
我考虑过的一种解决方法是设置jQuery
来检测.pagination > li
上的click
事件,但是我只是想问一下RactiveJS是否可以为我做到这一点,或者我只是缺少了什么. /p>
祝你有美好的一天!
如果要添加动态模板,请使用部分模板:
data: {
foo: 'foo',
paging: function(x){
var template = '<li on-click="clicked()">' + x + '</li>';
if (!this.partials.paging) {
this.partials.paging = template;
}
else {
this.resetPartial('paging', template);
}
return 'paging';
}
},
请参见 http://jsfiddle.net/fz7adjm4/
I have a paging function since it's a little bit tricky to do it in the templates. The problem is that if I place it like this:
{{ paging( rows, limit, offset ) }}
It will obviously escape the output , so I tried with triple-stache and the output is as expected. But then, it wont detect on-click
events anymore.. any suggestions ?
A workaround I thought about is setting jQuery
to detect the click
event on the .pagination > li
but I just wanted to ask if there's any way RactiveJS can do that for me or I'm just missing something.
Have a great day !
Use a partial if you want to add dynamic templating:
data: {
foo: 'foo',
paging: function(x){
var template = '<li on-click="clicked()">' + x + '</li>';
if (!this.partials.paging) {
this.partials.paging = template;
}
else {
this.resetPartial('paging', template);
}
return 'paging';
}
},
See http://jsfiddle.net/fz7adjm4/
这篇关于三重胡须上的RactiveJS事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!