如果Meteor应用程序失去网络连接,我试图这样做,以便禁用某些按钮。
出于某种原因,此代码中断了。如果我将{{criticalButton}}
移动到其他地方,例如在<p>
标记内,则可以正常工作。但是在<button>
内,我收到了以下错误。
HTML:
<button class="btn btn-primary" {{criticalButton}}>Update</button>
咖啡:
Template.registerHelper 'criticalButton', ->
return not Meteor.status().connected and 'disabled="disabled"'
控制台错误:
"Exception from Tracker recompute function: String contains an invalid character
AttributeHandler.prototype.update@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1057:4
ElementAttributesUpdater.prototype.update@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1372:6
.visitTag/updateAttributes@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1477:8
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13
.visitTag@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1482:10
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:103:0
.visitArray@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1416:6
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:116:0
.visitTag@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1495:30
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:103:0
doMaterialize@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1933:29
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
doRender@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1931:6
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13
Blaze._materializeView/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1922:0
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
Blaze._materializeView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1921:2
.visitObject@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1513:21
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:118:13
doMaterialize@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1933:29
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
doRender@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1931:6
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13
Blaze._materializeView/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1922:0
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
Blaze._materializeView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1921:2
.visitObject@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1513:21
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:118:13
doMaterialize@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1933:29
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
doRender@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1931:6
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13
Blaze._materializeView/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1922:0
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
Blaze._materializeView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1921:2
.visitObject@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1513:21
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:118:13
doMaterialize@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1933:29
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
doRender@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1931:6
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13
Blaze._materializeView/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1922:0
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
Blaze._materializeView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1921:2
.visitObject@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1513:21
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:118:13
.visitArray@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1416:6
.visit@http://localhost:3000/packages/htmljs.js?567eb96d5d22631c03d6aca6afa4c42f0d1295f2:116:0
doMaterialize@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1933:29
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:525:11
doRender@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1931:6
viewAutorun/</<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1821:15
Template._withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:3382:11
viewAutorun/<@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1820:0
Blaze._withCurrentView@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:2105:11
viewAutorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1819:0
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:308:4
Tracker.Computation@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:224:4
Tracker.autorun@http://localhost:3000/packages/tracker.js?21f0f4306879f57e10ad3a97efe9ea521c5b5775:499:10
Blaze.View.prototype.autorun@http://localhost:3000/packages/blaze.js?4e49999979a58da0e2265f7bd3f5910f9901b07b:1831:13"
答案 0 :(得分:1)
试试这个:
HTML
<button class="btn btn-primary" disabled="{{criticalButton}}">
Update
</button>
咖啡
Template.registerHelper 'criticalButton', ->
return not Meteor.status().connected
您可以从Blaze帮助器返回一个布尔值,以指示“boolean”HTML属性的值,如disabled,checked,required等...