我有一个Marionette CollectionView,它将<select>ItemView呈现为菜单,每个ItemView渲染为<option>.我的问题是,当我在CollectionView上调用'change'事件(意味着用户选择了一个选项)时,如何<option>从ItemView中获取所选模型?
var singleView = Marionette.ItemView.extend({
template: '#optionTemplate',
tagName: 'option'
});
var listView = Marionette.CollectionView.extend({
itemView: singleView,
tagName: 'select',
id: 'my-selector',
events: {
'change': 'optionSelected'
},
optionSelected: function() {
// I need to get the model from within this function
}
});
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何采用一个小矩阵(B下面的矩阵)并将值添加到A某个索引处的较大矩阵(下面的矩阵)中.看起来numpy对于这种情况来说是一个不错的选择,但我无法弄清楚如何做到这一点.
矩阵A:
[[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]]
Run Code Online (Sandbox Code Playgroud)
矩阵B:
[[2, 3, 4]
[5, 6, 7]
[8, 9, 3]]
Run Code Online (Sandbox Code Playgroud)
期望的最终结果:
[[0, 0, 0, 0, 0, 0]
[0, 0, 2, 3, 4, 0]
[0, 0, 5, 6, 7, 0]
[0, 0, 8, 9, 3, 0]
[0, 0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud)