使用ember添加Dropbox选择器
Adding Dropbox chooser using ember
我正在尝试将Dropbox选择器集成到我的ember应用程序中。这是由dropbox生成的代码片段。
<script type="text/javascript" src="https://www.dropbox.com/static/api/1/dropins.js" id="dropboxjs" data-app-key="XXXXXXXXXXX"></script>
<input type="dropbox-chooser" name="selected-file" id="db-chooser"/>
<script type="text/javascript">
document.getElementById("db-chooser").addEventListener("DbxChooserSuccess",
function(e) {
alert("Here's the chosen file: " + e.files[0].link)
}, false);
</script>
这是我在ember中尝试实现它的方式。
在应用程序布局文件中包含<script type="text/javascript" src="https://www.dropbox.com/static/api/1/dropins.js" id="dropboxjs" data-app-key="XXXXXXXXXXX"></script>
。
window.App = Ember.Application.create({
rootElement: '#ember-app',
customEvents: {
DbxChooserSuccess: "DbxChooserSuccess"
},
)};
App.TestView = Em.View.extend({
templateName: "test_view",
tagName: "li",
testAction: function(e) {
alert("DbxChooserSuccess event triggered");
}
});
//test_view.js.hjs
<input type="dropbox-chooser" name="selected-file" id="db-chooser" {{action "testAction" on="DbxChooserSuccess" target="view"}}/>
这不起作用。我的问题是我们如何添加自定义事件监听器 html 元素在ember?
直接通过javascript使用Dropbox选择器怎么样(在选择器文档页面的中间部分)
javascript:App.IndexController = Ember.ArrayController.extend({
dropboxChooser: function() {
Dropbox.choose({
linkType: "direct",
multiselect: false,
success: function(files) {
// Required. Called when a user selects an item in the Chooser
alert("Here's the file link:" + files[0].link);
},
cancel: function() {}
});
}
});
模板:
<button {{action dropboxChooser}}>Choose Dropbox File</button>
Sort of functional JSBin (no valid data-app-key
)
相关文章:
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 在动态创建的元素上获取对特定选择器的引用
- AngularJS-在JSON选择器中使用变量名
- 每当您在选择器内移动鼠标时,悬停功能就会重复
- 使用CSS或js,使用动态选择器选择任意li的下一个元素
- jQuery最近父级的数据属性选择器
- 为什么不'在JQuery中找到第二个css选择器的工作
- 为什么 .focus() 不起作用,而 .css(“color”,“red”) 在同一个选择器上起作用
- jquery IE7中的第n个选择器
- 在使用java使用dropbox选择器从dropbox中提取文件后,如何将文件存储在服务器中
- 避免使用Dropbox选择器登录
- 如何在一个页面上实现多个 Dropbox Javascript 选择器
- 如何让 Dropbox 选择器作为 SharePoint 2010 Visual Webpart 工作
- 使用ember添加Dropbox选择器
- "error": "无效来源"使用dropbox选择器
- Dropbox和Box选择器不能在默认的Chrome页面上工作
- 添加许多dropbox选择器与不同的扩展选项不工作
- Dropbox选择器返回损坏的文件
- Dropbox API选择器与JS从localhost: Origin不匹配任何应用程序域
- Dropbox选择器:获取javascript文件的内容