5.6 Components -- Handling User Interaction with Actions

1. 组件允许你定义你可以在你的整个应用程序中重用的控件。如果它们够通用,它们也可以在被共享给其他人并且在许多应用程序中被使用。

2. 为了使一个可重用的控件有用,然而,你首先需要你的应用程序的用户和它交互。

3. 你可以通过使用{{action}}辅助器使在你组件中的元素可交互。这和应用程序templates中的{{action}}一样,但是当在模板内部使用时有一个重要的区别。

4. 而不是像模板的控制器发送一个action,然后冒泡到路由层次,来自模板内部的actions被直接发送到模板的Ember.Component实例,并且不会冒泡。

5. 例如,假设下面的组件显示一个post的标题,当这个标题被点击,整个post的内容会被显示:

app/templates/components/post-summary.hbs

<h3 {{action "toggleBody"}}>{{title}}</h3>
{{#if isShowingBody}}
  <p>{{{body}}}</p>
{{/if}}

app/components/post-summary.js

export default Ember.Component.extend({
  actions: {
    toggleBody() {
      this.toggleProperty(‘isShowingBody‘);
    }
  }
});

{{action}}辅助器可以接收参数,监听不同的事件类型,控制如果发生冒泡,还有更多。

时间: 2024-10-13 01:44:48

5.6 Components -- Handling User Interaction with Actions的相关文章

【转】(五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components

原创至上,移步请戳:(五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components 4.Interaction Components 本节涵盖了处理交互,例如鼠标或触摸事件和使用键盘或控制器交互的 UI系统中的组件. 4.1 Selectable BaseClass 所有交互组件都有一些共同点.selectables是他们所有的控件的基类,这意味着他们都有共享状态,之间的前瞻转换和导航到其他使用键盘或控制器的selectables 的内置功能

Learning JavaScript Design Patterns -- A book by Addy Osmani

Learning JavaScript Design Patterns A book by Addy Osmani Volume 1.6.2 Tweet Copyright © Addy Osmani 2015. Learning JavaScript Design Patterns is released under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 unported license. It

Atitit WebDriver技术规范原理与概念

1. Book haosyo ma1 2. WebDriver是W3C的一个标准,由Selenium主持.1 3. WebDriver如何工作 (zhuan)1 1. Book haosyo ma 2. WebDriver是W3C的一个标准,由Selenium主持. W3C的浏览器测试和工具(Browser Testing and Tools)工作组发布了WebDriver的工作草案.该规范定义了WebDriver的应用编程接口.WebDriver是一个平台和语言中立的访问接口,允许应用程序或脚

JDWP Agent

Implementation Description Revision History Disclaimer 1. About this Document 1.1 Purpose 1.2 Intended Audience 1.3 Using This Document 1.4 Conventions and Symbols 2. Overview 2.1 About JPDA 2.2 The JDWP Agent 2.2.1 Key Features 2.3 JDWP Tests 2.3.1

jsp 是什么 ,jsp 隐式对象

google 搜索 java server page http://www.oracle.com/technetwork/java/javaee/jsp/index.html http://docs.oracle.com/javaee/5/tutorial/doc/bnagx.html 5.  JavaServer Pages Technology 6.  JavaServer Pages Documents 7.  JavaServer Pages Standard Tag Library 8

Programming With Objective-C---- Encapsulating Data ---- Objective-C 学习(三) 封装数据

Programming with Objective-C Encapsulating Data In addition to the messaging behavior covered in the previous chapter, an object also encapsulates data through its properties. 除了前一章讲述的消息方法(messaging behavior), 对象还能通过它的特性(properties)来封装数据. This chapte

[Flux] 2. Overview and Dispatchers

Flux has four major components: Stores, Dispatchers, Views, and Actions. These components interact less like a typical MVC and more like an Event Bus. src/js/dispatchers/app-dispatcher.js var Dispatcher = require('flux').Dispatcher, assign = require(

JavaEE学习之路-Sharing Information

Web components, like most objects, usually work with other objects to accomplish their tasks. Web components can do so by doing the following. Using private helper objects (for example, JavaBeans components). Sharing objects that are attributes of a

【IOS笔记】Gesture Recognizers

Gesture Recognizers Gesture recognizers convert low-level event handling code into higher-level actions. They are objects that you attach to a view, which allows the view to respond to actions the way a control does. Gesture recognizers interpret tou