• 页面视图中的按钮操作指向


    页面模板中的操作交互按钮,默认指向该模板对应的控制器。当然也可以指向相对应的路由和视图,只需要在这些类里面定义该操作处理函数即可,例如

    {{#if isExpanded}}
      <div class='body'>{{body}}</div>
      <button {{action 'contract'}}>Contract</button>
    {{else}}
      <button {{action 'expand'}}>Show More...</button>
    {{/if}}

    App.PostController = Ember.ObjectController.extend({
      // initial value
      isExpanded: false,
    
      actions: {
        expand: function() {
          this.set('isExpanded', true);
        },
    
        contract: function() {
          this.set('isExpanded', false);
        }
      }
    });

    App.PostRoute = Ember.Route.extend({
      actions: {
        expand: function() {
          this.controller.set('isExpanded', true);
        },
    
        contract: function() {
          this.controller.set('isExpanded', false);
        }
      }
    });

    App.PostsIndexView = Ember.View.extend({
      actions: {
        select: function(post) {
          // do your business.
        }
      }
    });
     
     
     
  • 相关阅读:
    stm32 usart 串口
    stm32 usart 串口
    stm32 PWM
    stm32 PWM
    stm32 定时器 通用定时器
    stm32 定时器 通用定时器
    stm32 外部中断
    linux+jre+apache+mysql+tomcat调优
    Cent OS服务器配置(JDK+Tomcat+MySQL)
    linux---文本编辑vi
  • 原文地址:https://www.cnblogs.com/toward-the-sun/p/4235702.html
Copyright © 2020-2023  润新知