- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 Sproutcore 还很陌生,但我对 Handlebars 很熟悉。我已经完成了 Todo 教程并检查了一些其他示例。
我喜欢它的一切,并且想在 Backbone 上使用它,但我很难理解如何连接自定义控件。我可以看到一些数据将在绑定(bind)中发挥作用,但我会迷失在触发事件中。
举个例子,如果我有一个链接列表,我想用它来过滤它下面的数据,我该如何绑定(bind)到事件?我知道在主干中你会使用事件和选择器:“click .link”
任何帮助将不胜感激!
最佳答案
听起来您想要循环遍历对象列表并创建链接,单击该链接时,会调用一些有权访问原始对象的 JavaScript 代码。
目前,最简单的方法是将模板上下文绑定(bind)到新的自定义 View 。您可以在此 JSFiddle 中看到所有操作:http://jsfiddle.net/67GQb/
模板:
{{#each App.people}}
{{#view App.PersonView contentBinding="this"}}
<a href="#">{{content.fullName}}</a>
{{/view}}
{{/each}}
应用程序代码:
App = SC.Application.create();
App.Person = SC.Object.extend({
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
App.people = [
App.Person.create({ firstName: "Yehuda", lastName: "Katz" }),
App.Person.create({ firstName: "Tom", lastName: "Dale" })
];
App.PersonView = SC.View.extend({
mouseDown: function() {
// Note that content is bound to the current template
// context in the template above.
var person = this.get('content');
alert(person.get('firstName'));
}
});
也就是说,我们知道这有点麻烦,并且有一些进一步简化流程的想法,我们将在未来几周内开展工作。
关于sproutcore - 在 Sproutcore 2 中编写自定义控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7174487/
在 Sproutcore 芯中,我试图在用户将鼠标悬停在div上时更改div的边框粗细。所有其他代码都正常工作,但是我找不到如何直接访问css属性或将新的类名附加到div的方法。 borderDiv:
两个绝对的初学者问题。 我的main.js enterState中有工作代码。 enterState: function(context) { .. //keepAlive var now = SC.
SC.Gridview是否支持分组?如果是这样,有人可以给我一些指导如何入门吗? 我正在尝试构建分为逻辑组的图块的gridview。我的基础模型类似于以下内容: TestApp.personModel
我正在尝试创建与 Sproutcore 文档中所示的相同的东西 http://docs.sproutcore.com/ 左侧的搜索字段及其下方的动态更改内容。 我已经用它的contentBinding
我现在只是在学习SproutCore,看起来很棒。但是我找不到关于部署选项的好答案。 我从小开始。只需使用SproutCore实现复杂站点的单个页面即可。现在,该页面是由我基于django的服务器动态
如果要执行更多的功能,我们如何在 Sproutcore 版本2.0中编写模型,例如我必须做多个选择和过滤列表。 最佳答案 Sproutcore是主要的MVC。这意味着模型的关注点与 View 的关注点
我认为将Sproutcore checkout 会很有趣,但是我遇到了一个错误,似乎无法弄清。我正在关注有关使用框架编写微博的最新NetTuts +教程。我的代码如下: Microblog.mainP
命令之间的区别是什么: sproutcode gen app AppName 和 sc-init AppName 当我运行第一个时,我看到以下内容: ~ Created directory at ap
我正在测试新芽Todo的教程,并且在第5步中检查了代码,就我所知,它至少与我的代码相同,但是addButton不会响应click事件。 addTask: function () { var
在我的一个ListView中,除了几个“office”属性外,我还显示了属于另一个 Controller 的“distance”属性,而orderBy仅适用于“office”模型属性。 背景:我有一个
我想确保在用户离开页面之前将数据保存在我的 Sproutcore 应用程序中。在Sproutcore中执行此操作的最佳方法是什么? 最佳答案 没有Sproutcore认可的特定方法。但是我做了一些看起
在学习 sproutcore 中的构建工具时,我遇到了下面的配置选项,它允许将名为“protocols”的目录中的文件包含在构建中。 :load_protocols => {Boolean} 但我的主
如果有人可以帮助我解决此问题,我将不胜感激。我正在关注在线指南,并且对Sproutcore还是陌生的。我创建了一个“HelloWorld”项目,并生成了HelloWorld.appController
如何在生产模式下运行 Sproutcore 项目? 您对我有很好的指导来学习 Sproutcore 吗? 谢谢。 最佳答案 一个SproutCore项目仅需要任何Web服务器,并在必要时需要一个后端来
我正在将自定义 View 重写为常规 View 。例如 Pseudo code if (date = today) { context.push('...; style="color:red;
我从 Sproutcore 和待办事项tutorial开始。我的输出如下图所示 我正在使用Chrome浏览器(Linux)。 Sproutcore主题不支持该浏览器? 或者我该如何解决? 谢谢。 最佳
我对 Sproutcore 还很陌生,但我对 Handlebars 很熟悉。我已经完成了 Todo 教程并检查了一些其他示例。 我喜欢它的一切,并且想在 Backbone 上使用它,但我很难理解如何连
在 Ember 从 sproutcore fork 之前,我选择了 sproutcore 作为框架。我不确定该走哪条路,并且对碎片化造成的努力明显稀释感到有点沮丧——因为这很少导致更好的事情。 Spr
如果我有通往应用程序深处某个状态的路由,我如何确保已完成正确的 Controller 设置,尽管我将直接进入内部状态? 例如, 状态 A 状态 a,表示路由:'a' 状态 B 状态 b,表示路由:'a
我正在使用 static_url引用位于资源目录中的静态文件。这适用于文字 URL 字符串,但不适用于使用变量构造的复合 URL: static_url(foo + '/' + bar) Spro
我是一名优秀的程序员,十分优秀!