Sproutcore菜单

时间:2012-02-24 00:23:35

标签: javascript sproutcore

我开始学习sproutcore(v1.7.1.beta)。我非常关心正确实施某些事情的问题......其中一个是主菜单。

这样做的正确方法是什么?

我想如果单击菜单项我需要更改状态,对吗?我尝试使用SC.TemplateCollectionView进行操作,但无法理解,如何确定点击了哪个项目?

我的CollectionView:

App.MainMenuItemView = SC.TemplateCollectionView.extend({
  contentBinding: 'App.mainMenuController',
  mouseUp: function(){
    //
  }
});

1 个答案:

答案 0 :(得分:1)

您想要使用

SC.SegmentedView。像

这样的东西
topNav: SC.SegmentedView.extend({
    classNames: ['top-nav'],
    items: [
        {
            title: "App.title1".loc(),
            value: 1,
            action: 'action1'
        },
        {
            title: "App.title2".loc(),
            value: 2,
            action: 'action2'

        },
        ....
    ],
    itemTitleKey: 'title',
    itemValueKey: 'value',
    itemWidthKey: '85',
    itemActionKey: 'action', 
    valueBinding: 'Binding to current tab value'
})          

您可以通过itemIconKey ....

指定图标

或者只是滚动自己的自定义SC.View。

相关问题