【问题标题】:Updateable jsRender template可更新的 jsRender 模板
【发布时间】:2023-04-08 23:01:01
【问题描述】:

模板渲染后,我需要根据模板内的字段进行更改。这里我做了一个不工作的例子:http://jsfiddle.net/DrZ25/3/

jsRender 渲染模板并更改每行输入字段会更改示例中的year,但如果将新电影添加到列表中 - 不会进行任何更改

有什么办法可以让它工作吗?

【问题讨论】:

    标签: javascript jquery jquery-templates jsrender


    【解决方案1】:

    您必须使用live 将事件绑定到input

    $("input").live('change',function() {
        var id = $(this).attr("id");
        var year = $(this).val();
    
        $( "#year-"+id ).html(year);
    });
    

    检查这个工作link

    【讨论】:

    • 实际上,从 jQuery 1.7 开始,您应该使用 on() 而不是 live()api.jquery.com/on
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多