简体   繁体   中英

Django, code inside <script> tag doesn't work in a template

I'm trying to use Bootstrap File Input in my django application. 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. Any script in this tag doesn't work. Tried to use $(document).ready(function(){}) in the beggining, but without result. 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM