RactiveJS events on tripple mustache

旧巷老猫 提交于 2020-01-06 19:05:54

问题


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 !


回答1:


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/



来源:https://stackoverflow.com/questions/29778586/ractivejs-events-on-tripple-mustache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!