Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在主干视图和文本的html模板文件之间进行交互!插件_Javascript_Backbone.js_Requirejs - Fatal编程技术网

Javascript 如何在主干视图和文本的html模板文件之间进行交互!插件

Javascript 如何在主干视图和文本的html模板文件之间进行交互!插件,javascript,backbone.js,requirejs,Javascript,Backbone.js,Requirejs,我在quoteTemplate.html(使用文本!插件)中循环数据,然后得到一个变量total=100,我想根据复选框事件在视图中打印total值: var testView = Backbone.View.extend({ initialize: function() { }, el: '#container', events : { 'change [name=chkIncludeTotal]' : 'checkboxHandler'

我在
quoteTemplate.html
(使用文本!插件)中循环数据,然后得到一个变量
total=100
,我想根据
复选框事件在
视图中打印
total
值:

var testView = Backbone.View.extend({
    initialize: function() {
    },
    el: '#container',
    events : {
        'change [name=chkIncludeTotal]' : 'checkboxHandler'
    },
    checkboxHandler : function (e) {
        if($(e.currentTarget).is(':checked')){
            $('#total').html(total);
        }else{
            $('#total').html(0);
        }
    },
    render: function(){
        var cartPanel = _.template(CartPanel);
        this.$el.html(cartPanel);

        var aa = _.template(AATemplate);
        var bb = _.template(BBTemplate);
        var cc = _.template(CCTemplate);

        var dd = _.template(eeTemplate, {data : test.showEEtemplate() , total:total});

       $('#div1').html(bb);
       $('#div2').html(cc);
       $('#div3').html(dd);

    }
});
我真的不知道如何从html模板文件中获取
total
,以便在视图中使用。
任何帮助都将不胜感激,谢谢。

啊,这是我的错别字,我会更新它
total
未存储在我的视图中,因为
total
是我在html文件的
循环中增加的值。html中的total类型是什么?你不能只用$(“#total”).val()吗?@muistooshort:如果我扔掉它,我怎么能在
checkboxHandler
函数中调用
total
。你的意思是,像我在
隐藏的
字段中存储
total
,然后我用
$('#hiddenID').val()把它取出吗?