<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    <li role="presentation">
      <a role="menuitem" tabindex="-1" href="#">{{model.name}}</a>
    </li>
  </ul>
</div>
这是引导程序下拉所需的基本代码
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"></ul>
那是我需要呈现为菜单项(文件,编辑等)的代码问题是保存菜单列表项的兄弟标签
我会使用这样的东西:
<a class="dropdown-toggle" data-toggle="dropdown" href="#">{{name}}</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"></ul>
然后我想将菜单列表项呈现到“ul.dropdown-menu”元素中:
<li role="presentation">
   <a role="menuitem" tabindex="-1" href="#">{{name}}</a>
</li>
这是我的木偶观点:
var menuItem = Marionette.ItemView.extend({
    tagName: 'a',
    attributes: {
        'class': 'dropdown-toggle',
        'data-toggle': 'dropdown',
        'href': '#'
    },
    initialize: function() {
        this.render();
    },
    render: function() {
        this.$el.html('test').after('<b>bam?</b>');
        return this;
    }
});
每当我调用渲染函数并尝试操作在创建时设置的 this.el 之外的数据时,它永远不会附加在标记之后。仅在内部(所以我在 a 标签内看到“测试”,但没有看到“bam?”。有人有处理兄弟元素的任何技巧吗?
我对 Backbone / Marionette 也没有经验,所以可能有更好的方法来解决这个问题,我只是不确定。