我在CompositeView中有一个函数:Marionette.CompositeView.extend({ childView: ItemView, onCheckMask: function() { alert('hello!') }, ...
我想从ItemView调用此函数:Marionette.ItemView.extend({ ... anotherFunction: function() {//here i want to call function 'onCheckMask'...}
我该怎么办?
最佳答案
假设您已将Marionette.CompositeView
实例化为myCompositeView
,只需在myCompositeView.triggerMethod('check:mask');
中执行anotherFunction()
即可;
这将在myCompositeView上调用onCheckMask。可以在Marionette docs中找到更多文档。
始终喜欢使用事件,而不是直接调用函数,可帮助您分离应用程序中的不同区域。
关于python - Marionette 如何从ItemView调用CompositeView函数?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29468195/