【发布时间】:2015-07-19 06:20:54
【问题描述】:
我正在编写一个简单的 chrome 扩展来通过 Dropbox 上传和共享文件。我想要的工作流程是:
1. Select file to upload.
2. Click upload button.
3. A bootstrap modal opens up asking for email ids to share the file with.
4. Once the user has submitted email id in the modal dialogue box and saved it then
the upload function should be called.
目前发生的情况是出现了模式,但在后台也调用了上传功能,我如何才能阻止它,直到用户成功提交输入。
编辑:
function startUpload()
{
$('#emailModal').modal({backdrop: 'static'});
//rest of the code to upload file via ajax call which needs to be
//stoppped from executing till modal has successfully submitted or exited
}
【问题讨论】:
-
你尝试了什么?你能提供一些代码吗?
-
在 Javascript 中,您不会“阻止”执行代码。因为浏览器 Javascript 是单线程的,阻塞或循环会阻止任何其他代码运行,包括您的模式。通常,您将使用上传完成时调用的回调来构建此类问题。
-
@SebastianNette 我已经在编辑中添加了尝试过的代码。
标签: javascript jquery twitter-bootstrap twitter-bootstrap-3