2015-12-17 24 views
1

我試圖在我的django應用程序中使用引導文件輸入。我已將所有必需的文件加載到標題中。這裏是我的形式:Django,<script>中的代碼在模板中不起作用

<form enctype="multipart/form-data"> 
<div> 
<input id="file1" name="file1[]" class ="file" type="file" multiple="multiple"> 
<div> 
</form> 

引導文件輸入工作正常。但我需要配置一些選項。在教程和實例它的外觀那樣:

<script> 
$('#file1').fileinput({ 
    showUpload: false, 
}); 
</script> 

守則腳本標籤中不起作用。這個標籤中的任何腳本都不起作用。試圖在開始時使用$(document).ready(function(){}),但沒有結果。它有什麼問題?腳本追隨形式。

+0

聽起來像有一個與$發生衝突。你有沒有試過jQuery('#file1')。fileinput({.... etc etc? –

+0

你看到在JavaScript控制檯中的任何錯誤?你看到jquery和bootstrap js文件加載在網絡選項卡上嗎? – Anentropic

+0

謝謝js控制檯中沒有錯誤,jquery&bootstrap文件加載正常。我試過jQuery('#file1')。fileinput({....等等,它在我的情況下不起作用。 – Swallow

回答

0

可能是你可以試試這個:

<input id="file1" name="file1[]" type="file" multiple class="file-loading"> 
<script> 
$(document).on('ready', function() { 
    $("#file1").fileinput({ 
     showUpload: false, 
    }); 
}); 
</script> 
相關問題