【问题标题】:TextFieldView does not seem to have been loadedTextFieldView 似乎没有加载
【发布时间】:2011-06-04 13:34:24
【问题描述】:

我正在尝试从SC.TextFieldView 获得任何结果,但是很遗憾,它始终返回undefined。所有其他视图类似乎都在工作。

【问题讨论】:

  • 向我们展示代码。您应该将文本字段的值绑定到控制器。
  • 即使是在 Firebug 控制台中探测 SC.TextFieldView 等基本操作,也会返回“未定义”
  • @xantus 你具体在做什么......没有代码就帮不了你
  • 没有比 TODO 示例更有趣的了。我用的是1.6.0rc2 问题是因为一个奇怪的原因,刚启动的时候,一堆类,比如TextFieldView,ButtonView等没有加载,导致一堆错误

标签: javascript sproutcore


【解决方案1】:

如果您启动一个新的 sproutcore 模板项目,则默认情况下仅加载 core_foundation 类。这意味着只有那些在您的主 sproutcore 构建文件中被定义为依赖项:

config :all, :required => "sproutcore/core_foundation", :theme => "sproutcore/empty_theme"

在大多数情况下,这是完全有道理的,因为在 sproutcore 1.5 中引入的模板视图系统不能很好地与模板结合使用。虽然,可以在“传统”sproutcore 视图中使用模板视图,例如SC.ContainerView(详见http://guides.sproutcore.com/using_handlebars.html#using-sc-templateview-inside-desktop-controls)你不能在模板视图中使用传统的sc桌面视图。

因此,当您开始一个新的模板项目时,桌面视图不会包含在构建文件中。但是,默认情况下也不包含其他一些有用的 sproutcore 模块,例如ajax 模块、数据存储或状态图模块。如果要使用这些模块,则必须调整构建文件并包含这些模块。它可能看起来像这样

config :all, 
    :required => [ 
        "sproutcore/core_foundation",
        "sproutcore/datastore",
        "sproutcore/statechart",
        "sproutcore/ajax" ]
    :theme => "sproutcore/empty_theme"

包含特定模块或只是

config :all, :required => "sproutcore", theme => "sproutcore/empty_theme"

包括所有可用的sproutcore 模块。如果您想使用提供的组件启动传统的 sproutcore 项目,只需使用

# sc-init your-project

而不是

# sc-init your-project --template

这样,您将从一开始就得到正确的构建文件。当您从 sproutcore 开始时可能会感到困惑,但应该知道构建 sproutcore 模板应用程序与使用提供的桌面控件构建 sproutcore 应用程序是不同的。虽然,提供了路径来将现有的桌面类应用程序转换为模板应用程序,但不支持相反的方式(目前)。

【讨论】:

    【解决方案2】:

    您需要在项目的 Buildfile 中添加基础作为依赖项:

    config :all, :required => ["sproutcore/core_foundation", "sproutcore/foundation"]
    

    【讨论】:

      猜你喜欢
      • 2021-09-20
      • 1970-01-01
      • 2013-10-08
      • 1970-01-01
      • 1970-01-01
      • 2016-07-26
      • 1970-01-01
      • 1970-01-01
      • 2014-05-22
      相关资源
      最近更新 更多