[英]Django, code inside <script> tag doesn't work in a template
I'm trying to use Bootstrap File Input in my django application. 我正在尝试在django应用程序中使用Bootstrap File Input 。 I've loaded all necessary files in header.
我已经在标头中加载了所有必需的文件。 Here is my form:
这是我的表格:
<form enctype="multipart/form-data">
<div>
<input id="file1" name="file1[]" class ="file" type="file" multiple="multiple">
<div>
</form>
Bootstrap File Input works fine. 引导文件输入工作正常。 But I need to configure some options.
但是我需要配置一些选项。 In tutorial and examples its looks like that:
在教程和示例中,其外观如下所示:
<script>
$('#file1').fileinput({
showUpload: false,
});
</script>
Code inside the script tag doesn't work. script标签内的代码不起作用。 Any script in this tag doesn't work.
此标记中的任何脚本均无效。 Tried to use $(document).ready(function(){}) in the beggining, but without result.
试图在开始使用$(document).ready(function(){}) ,但没有结果。 What can be wrong with it?
这有什么问题呢? Script goes after form.
脚本遵循形式。
May be you can try this : 也许你可以试试这个:
<input id="file1" name="file1[]" type="file" multiple class="file-loading">
<script>
$(document).on('ready', function() {
$("#file1").fileinput({
showUpload: false,
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.