Ember嵌套链接到不起作用

时间:2013-09-17 05:06:40

标签: ember.js

我正在尝试使用子菜单制作菜单,但没有运气:

<ul class="side-menu">
    {{#link-to 'reportSummary' tagName="li" href=false}}<a href="#"><span class="badge pull-right">17</span> <i class="icon-dashboard"></i>Рабочий стол</a>{{/link-to}}
    {{#link-to 'remarkList' tagName="li" href=false}}
        <a href="#"><span class="badge pull-right">17</span> <i class="icon-bar-chart"></i>Замечания</a>
        <ul class="sub-menu">
            {{#link-to 'remarkState' 'review' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Исполнение</a>{{/link-to}}
            {{#link-to 'remarkState' 'approval' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Утверждение</a>{{/link-to}}
            {{#link-to 'remarkState' 'worker' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Объяснительная</a>{{/link-to}}
            {{#link-to 'remarkState' 'info' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Информация</a>{{/link-to}}
            {{#link-to 'myRemarks' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Мои замечания</a>{{/link-to}}
        </ul>
    {{/link-to}}
    {{#link-to 'refusalList' tagName="li" href=false}}<a href="#"><span class="badge pull-right">17</span> <i class="icon-terminal"></i>Отказы</a>{{/link-to}}
    {{#link-to 'complaintList' tagName="li" href=false}}<a href="#"><span class="badge pull-right">17</span> <i class="icon-th"></i>Жалобы</a>{{/link-to}}
</ul>

当我点击嵌套链接时,它根本不起作用,没有任何事件。有什么问题?

1 个答案:

答案 0 :(得分:3)

不要嵌入你的链接。 link-to helper使用一个特殊的视图LinkView,并使用它的click事件来调用转换。 当您嵌套两个这样的视图时,click事件会同时冒泡,使外部视图事件(称为最后一个事件)成为重要事件。

相反,你应该做类似的事情:

                    {{#link-to 'remarkList' tagName="li" href=false}}
                        <a href="#"><span class="badge pull-right">17</span> <i class="icon-bar-chart"></i>Замечания</a>
                    {{/link-to}}
                    <ul class="sub-menu">
                        {{#link-to 'remarkState' 'review' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Исполнение</a>{{/link-to}}
                        {{#link-to 'remarkState' 'approval' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Утверждение</a>{{/link-to}}
                        {{#link-to 'remarkState' 'worker' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Объяснительная</a>{{/link-to}}
                        {{#link-to 'remarkState' 'info' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Информация</a>{{/link-to}}
                        {{#link-to 'myRemarks' tagName="li" href=false}}<a href="#"><i class="icon-angle-right"></i>Мои замечания</a>{{/link-to}}
                    </ul>

将每个链接放到特定元素。