在我的對象,我需要有在某一個領域的額外內容之一的管理員change_form(如按鈕將做這一領域的一些JavaScript修改)Django的 - 一個字段旁邊管理員changeForm額外的內容
我把看看原始的change_form
模板,我發現我可以添加東西到塊content
,但我怎麼能添加,只是旁邊的某個領域?
例子:
<!-- ... -->
<div class="form-row part">
<div>
<label for="id_part" class="required">Part:</label>
<input id="id_part" type="text" class="vIntegerField" value="1" name="part" />
</div>
</div>
<div class="form-row text">
<div>
<label for="id_text" class="required">Text:</label>
<textarea id="id_text" rows="10" cols="40" name="text" class="vLargeTextField"></textarea>
</div>
</div>
<div class="form-row sequence">
<div>
<label for="id_sequence" class="required">Sequence:</label>
<input id="id_sequence" type="text" class="vIntegerField" value="3" name="sequence" />
</div>
</div>
<!-- ... -->
將成爲
<!-- ... -->
<div class="form-row part">
<div>
<label for="id_part" class="required">Part:</label>
<input id="id_part" type="text" class="vIntegerField" value="1" name="part" />
</div>
</div>
<div class="form-row text">
<div>
<label for="id_text" class="required">Text:</label>
<textarea id="id_text" rows="10" cols="40" name="text" class="vLargeTextField"></textarea>
</div>
<!-- extra content start -->
<div class="markup-tools">
<input type="button" class="tool1" value="Tool 1" />
<input type="button" class="tool2" value="Tool 2" />
<input type="button" class="tool3" value="Tool 3" />
</div>
<!-- extra content end -->
</div>
<div class="form-row sequence">
<div>
<label for="id_sequence" class="required">Sequence:</label>
<input id="id_sequence" type="text" class="vIntegerField" value="3" name="sequence" />
</div>
</div>
<!-- ... -->
有沒有辦法做到這一點,而不必與JS的內容,如附加:
$('.form-row.text').append('the content');
我發現,不非常可維護