三重胡须上的RactiveJS事件 [英] RactiveJS events on tripple mustache

查看:107
本文介绍了三重胡须上的RactiveJS事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有分页功能,因为在模板中执行此操作有些棘手.问题是,如果我这样放置它:

{{ 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事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆