应用程序崩溃使用reactiveVars(meteor.js)

时间:2016-02-24 06:30:12

标签: javascript meteor

我遇到运行Meteor.js应用程序的错误(使用reactiveVars):

错误阻止启动:

使用ecmascript处理文件时(对于目标web.browser): client / views / inquiry.js:67:2:client / views / inquiry.js:意外的令牌(67:2)

您的申请有错误。等待文件更改。

第67行是以辅助函数

中的report: function () {开头的那个

mysite.js:

if (Meteor.isClient) {

    Template.inquiry.onCreated( function() {
        //toggles 'thank you' on inquiry template
        this.showForm = new ReactiveVar( true );

        //toggles interest buttons on inquiry template 
        this.report = new ReactiveVar( false );
        this.consult = new ReactiveVar( false );
        this.contract = new ReactiveVar( false );
    });
}

inquiry.js:

Template.inquiry.helpers({

  //toggles 'thank you' on inquiry template
  showForm: function () {
    return Template.instance().showForm.get();
  }

  //toggles interest buttons on inquiry template 
  report: function () {
    return Template.instance().report.get();
  }
  contract: function () {
    return Template.instance().contract.get();
  }
  consult: function () {
    return Template.instance().consult.get();
  }


});

Template.inquiry.events({
    'click .button': function(event, template){

        var button_id=event.currentTarget.id

        $("#" + button_id).addClass('selected');

        if(button_id == 'report' && report == false) {
            template.report.set( true );
            $("#" + button_id).addClass('selected');
        }
        else if(button_id == 'consult' && consult == false) {
            template.consult.set( true );
            $("#" + button_id).addClass('selected');
        }
        else if(button_id == 'contract' && contract == false) {
            template.contract.set( true );
            $("#" + button_id).addClass('selected');
        }
        else if(button_id == 'report' && report == true) {
            template.report.set( false );
            $("#" + button_id).removeClass('selected');
        }
        else if(button_id == 'consult' && consult == true) {
            template.consult.set( false );
            $("#" + button_id).removeClass('selected');
        }
        else if(button_id == 'contract' && contract == true) {
            template.contract.set( false );
            $("#" + button_id).removeClass('selected');
        }

    }
});

1 个答案:

答案 0 :(得分:1)

除了最后一个helper之外,你需要放置一个comma以便在流星中正确构建。

showForm: function () {
return Template.instance().showForm.get();
},