加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – 如何使用Ember.js创建和管理Twitter Boots

发布时间:2020-12-17 21:27:45 所属栏目:安全 来源:网络整理
导读:我能够得到一个很好的bootstrap模式来正确显示/隐藏并显示存储在模态控制器上的msg,如下所示: Ember Bootstrap Modal Example 相关代码{ // contextscript type="text/x-handlebars" data-template-name="application" div class="container" {{outlet}} /d
我能够得到一个很好的bootstrap模式来正确显示/隐藏并显示存储在模态控制器上的msg,如下所示:
Ember Bootstrap Modal Example

相关代码{

// context
<script type="text/x-handlebars" data-template-name="application"> 
  <div class="container">
    {{outlet}}
  </div>
  <div id="modal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="ariaLabel" aria-hidden="true">
    {{render "modal"}}
  </div>
</script>

// modal template
<script type="text/x-handlebars" data-template-name="modal">
  <div class="modal-header"> 
    <h2>{{title}}</h2> 
  </div>
  <div class="modal-body"> 
    <h4>{{{msg}}}</h4>
  </div>
  <div class="modal-footer">
    <div class="span3 pull-right">
      <button 
        id="modalBtn" data-dismiss="modal" aria-hidden="true" style="vertical-align:bottom"
        {{bindAttr class=":btn :btn-large :btn-block isCorrect:btn-success:btn-danger" }} 
        {{action "callback"}}>
        {{btn}}
      </button>
    </div>
  </div>
</script>
// controllers
App.HomeController = Ember.Controller.extend({
  needs: ['modal'],showModal: function(){
    var modCon = this.get('controllers.modal');

    if( modCon.get('isCorrect') ){ // some logic
      modCon.setProperties({
        title: 'Correct',msg: 'You get points',btn: 'Next'
      });
    }
    else{
      modCon.setProperties({
        title: 'Incorrect',msg: 'Please try again',btn: 'Close'
      });
    }
    $('#modal').modal(); // show
  }
});

App.ModalController = Ember.Controller.extend({
  isCorrect: true,title: 'modCon title',msg: 'modCon message',btn: 'modCon btn label',callback: function(){
     alert('modal controller caught action');
  }
});

我在这里发布这个有两个原因:

>我做得对吗?使用Ember可能很难理解开发人员如何实现某些事情.
>如果其他人可以帮助改进/验证它的有效性,那么它可以作为那些希望在Ember.js中实现Bootstrap模态的人的一个例子.

解决方法

对于Ember CLI用户,以下是一些最近的方法/链接更新:

https://github.com/mattbeedle/ember-cli-bootstrap-modal-example

http://indexiatech.github.io/ember-components/#/overview

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读