在EmberJS应用中使用Bootstrap -for-ember创建Twitter引导模式
Creating a Twitter Bootstrap modal in an EmberJS application using bootstrap-for-ember
按照这里的指导,以编程方式创建一个模态对话框。
<h1 class="page-header">Welcome!</h1>
{{bs-button title="Create Modal" clicked="createModalProgramatically"}}
我创建了一个modal_controller.js
文件,并在其中:
MyEmberApp.IndexController = Ember.Controller.extend({
manualButtons: [
Ember.Object.create({title: 'Submit', clicked:"submitManual"}),
Ember.Object.create({title: 'Cancel', dismiss: 'modal'})
],
actions: {
submitManual: function() {
Bootstrap.NM.push('Modal destroyed!', 'success');
return Bootstrap.ModalManager.close('manualModal');
},
createModalProgramatically: function() {
//@property {string} The name of the modal, required later to close the modal (see submitManual function above)
//@property {string} The title of the modal.
//@property {string} The template name to render within the modal body, a View class may also be specified.
//@property {array} Array of Button meta data
//@property {object} The controller instance that instantiate the modal.
Bootstrap.ModalManager.open('manualModal', 'Hello', 'index', this.manualButtons, this);
}
}
});
我想扩展ApplicationController (而不是索引控制器),因为我希望能够从应用程序中的任何地方以编程方式调用模态对话框。
我怎么能做到这一点没有重复我的模态代码在每个控制器我想使用模态?
我在这里错过了什么?谢谢!
您可以将Bootstrap代码放入控制器中,如MyBootstrapController
:
MyEmberApp.MyBootstrapController = Ember.Controller.extend({
manualButtons: [
Ember.Object.create({title: 'Submit', clicked:"submitManual"}),
Ember.Object.create({title: 'Cancel', dismiss: 'modal'})
],
actions: {
submitManual: function() {
Bootstrap.NM.push('Modal destroyed!', 'success');
return Bootstrap.ModalManager.close('manualModal');
},
createModalProgramatically: function() {
Bootstrap.ModalManager.open('manualModal', 'Hello', 'index', this.manualButtons, this);
}
}
});
,然后让你所有的下一个控制器继承MyBootstrapController
,像这样:
MyEmberApp.IndexController = MyEmberApp.MyBootstrapController.extend({
// Some other controller stuff
});
相关文章:
- 如何创建一个“下一步”按钮,使用 Java 脚本和 Twitter Bootstrap 切换选项卡
- 创建一个复选框按钮的散列,这些按钮在单击时在Twitter Bootstrap Button组中处于活动状态
- JQuery.click,nor.on(“click”,..)与使用函数创建的ASP.NET和twitter boost
- Twitter 引导程序提前类型无法添加到动态创建的元素
- 创建来自 Twitter REST API 实体(主题标签、链接、提及等)的推文文本的链接
- 如何在 Twitter 引导流畅布局中创建多个可滚动部分
- 有没有一种方法可以使用Twitter引导程序创建多个对话框
- Twitter引导程序下拉列表创建了一个滚动条
- 如何在JavaScript中创建Twitter状态更新,并从中接收响应
- 如何使用HTML/Twitter Bootstrap/Jquery Mobile等创建简单的iOS类型的表视图
- Twitter Widget创建不起作用
- 在Twitter引导程序中创建网格跨度之间的空间
- 多个JS创建的twitter按钮:跟踪点击了哪个按钮
- 为twitter创建API以显示最新的5个帖子
- 在EmberJS应用中使用Bootstrap -for-ember创建Twitter引导模式
- 使用angular2创建类似twitter的可嵌入组件
- 使用twitter bootstrap模式创建一个带有图像/内容的图库
- 如何创建按钮小部件,如facebook / twitter
- JS Twitter小部件总是创建新的换行,需要在同一行
- 重新创建或更改twitter按钮的参数