所以我有海边申请。第一个组件只渲染一个子组件:
MCRootComponent>>initialize
super initialize.
self main: MCMainComponent new.
MCRootComponent>>renderComponentOn:html
renderContentOn: html
html render: main
现在渲染的子组件看起来像:
MCMainComponent>>renderContentOn: html
html tbsForm:[
html tbsContainerFluid: [
html anchor
callback: [ self call: (MCServiceOrderComponent from: MCServiceOrder new)];
with: 'New Service Order' ]]
和MCServiceOrderComponent:
MCServiceOrderComponent>>initialize
super initialize.
customerComponent := MCClienteComponent new.
vehicleComponent := MCVehicleComponent new.
vehicleComponent lookupCallback: [
self show:(MCVehicleLookupComponent new) onAnswer:[:vehicle|
vehicle ifNotNil: [
serviceOrder vehicle: vehicle.
vehicleComponent objectToRender: vehicle.
customerComponent objectToRender: vehicle customer ]]]
MCServiceOrderComponent>>renderContentOn: html
html heading level1 with: 'ServiceOrder'.
html tbsForm with: [
html render: vehicleComponent.
html render: customerComponent.
]
到目前为止,这一切都很好。注意,查找回调被传递给MCVehicleComponent。此块将传递给MCVehicleComponent内呈现的按钮上的回调。
MCVehicleComponent>>renderContentOn: html
self renderContainer: 'Vehicle' on: html with: [
self renderSearchFor: #id on: html with: self lookupCallback.
self renderInputFor: #maker on: html.
self renderInputFor: #model on: html.
self renderInputFor: #color on: html ]
MCVehicleComponent>>renderSearchFor: aSymbol on: html with: aBlock
html tbsFormGroup: [
html label: aSymbol asCapitalizedPhrase.
html tbsInputGroup: [
html textInput tbsFormControl on: aSymbol of: self objectToRender.
html tbsInputGroupButton: [
html tbsButton callback: aBlock;
with: [ html tbsGlyphIcon iconSearch ] ] ]]
它应该#call:到MCVehicleLookupComponent并返回结果。但事实是,只要#call:它发出,页面内容就会变成空白。我试过直接从MCMainComponent调用MCVehicleLookupComponent,它工作正常,所以我知道问题不存在。你知道可能导致这种行为的原因吗?
我在smalltalk上相当新,所以请耐心等待愚蠢的问题和可怕的代码(这是我的第一个申请。欢迎任何建议。)
答案 0 :(得分:0)
原来我说的是错误的组件。一切都充满了魅力。遗憾。