問題は2番目の後show view
です。 this.ui.uielemnet
は要素ではなく文字列セレクタのみを返します。イベントやその他のロジックはうまく動作しますが、私はt get element after second
を表示することができます. In the first
show view`すべてが計画通りに動作します。Marionette JS 3:2番目のショービューの後にuiに文字列セレクタがあります
コードは以下のとおりです。私は説明のためにコンソールログを追加します。 CoffeeScriptの)
ルータ:
class App.Routers.PanelRouter extends Marionette.AppRouter
initialize: (options = {}) ->
@mainView = options.cpView
routes:
'sbis-docs(/)': 'sbisDocShow'
'sbis-send(/)': 'sbisSendShow'
sbisDocShow: ->
view = new App.Views.SbisDoc
@mainView.getRegion('childRegion').show view
view.showTable()
sbisSendShow: ->
view = new App.Views.SendSbis
@mainView.getRegion('childRegion').show view
part of view
class App.Views.SendSbis extends Marionette.View
template: _.template(App.Templates.SbisSend);
initialize:() ->
vent.on('event:change-search-method', @changeSearchMethod)
vent.on('event:change-send-method', @changeSendMethod)
changeSearchMethod: (data) =>
if data.checked
@ui.cust.attr('placeholder', 'Customer ID')
@ui.labelCust.text('Номер договора')
else
@ui.cust.attr('placeholder', 'Логин')
@ui.labelCust.text('Логин пользователя')
changeSendMethod: (data) =>
console.log @ui.month
if data.checked
@ui.month.prop('disabled', false)
else
@ui.month.prop('disabled', true)
ui:
sendDocs: '#send-docs'
form: '#form-docs'
cust: '#cust'
year: '#year'
month: '#month'
labelCust:'#label-cust'
その他のビュー:
class App.Views.SetupSend extends Marionette.View
template: _.template(App.Templates.SetupSend)
onAttach: ->
@ui.checkboxes.bootstrapToggle()
ui:
search: '#search-method'
send: '#send-method'
checkboxes: 'input[type=checkbox][data-toggle^=toggle]'
events:
'change @ui.search': 'changeSearchMethod'
'change @ui.send': 'changeSendMethod'
changeSearchMethod: (e) ->
vent.trigger('event:change-search-method', e.target)
changeSendMethod: (e) ->
vent.trigger('event:change-send-method', e.target)
changeSendMethod: (data)
コンソールログでは初めてでは [input#month.form-control, prevObject: r.fn.init[1]]
ですが、私はCONSOLE.LOG再びルートとカムバックを変更したとき #month
です
もし私がを変更した場合は$(@ui.month).prop('disabled', false)
になります。しかし、なぜそれが起こり、どのように修正できるのか分かりません。