开发者

sproutcore main page refactoring

I build myself my fist sproutcore app. Now the code in resource/mainpage gets big. I wan开发者_C百科t to refactor the code so views are in their own seperate files.

How to do this?

example code

Tp.mainPage = SC.Page.design({
  mainPane: SC.MainPane.design({
  childViews: [SC.TabView.design({
    value: "welcome",
    items: [
        { title: "Welcome", value: "welcome"},
        { title: "route", value: "Tp.mainPage.contentview"},
        { title: "manifold", value: "manifold"},

    ],
    itemTitleKey: 'title',
    itemValueKey: 'value',
    layout: { left:12, right:12, top:12, bottom:12},
    userDefaultKey: "mainPane",
  })]
 }),
 welcome: SC.LabelView.design({ ..some code }),

 contentview: SC.SplitView.design({
  ..mucho code... }),

 manifold: SC.View.extend({
  ..mucho code... }),

I want to refactor out the mucho code parts.


sc-gen view Tp.WelcomeView --target=Tp

this will generate a a view in the views folder.

In your mainpage.js

welcome: Tp.WelcomeView.design({ ... maybe layout ... })

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜