collapsible inlines

This commit is contained in:
Sanj 2012-09-07 16:08:49 +05:30
parent dfd2427460
commit a880b14173

View File

@ -21,6 +21,10 @@
.delete-row {
display:none !important;
}
.inlineHidden {
display:none;
}
</style>
<!-- uni-form JS library, optional -->
<script src="/static/uni_form/uni-form.jquery.js" type="text/javascript"></script>
@ -177,13 +181,17 @@ $(function(){
{% crispy form form.helper %}
{% for inline in inlines %}
<div class="inlineWrapper">
<h3> {{inline.title }} </h3>
{% if inline.help_text %}
<div class="formset_help_text"> {{ inline.help_text }}</div>
{% endif %}
<div class="itf_formset" id="formset_{{inline.prefix}}">
{% crispy inline inline.form.helper %}
<div class="inlineHidden">
{% if inline.help_text %}
<div class="formset_help_text"> {{ inline.help_text }}</div>
{% endif %}
<div class="itf_formset" id="formset_{{inline.prefix}}">
{% crispy inline inline.form.helper %}
</div>
</div>
</div>
{% endfor %}
<br />
<input type="submit" value="Submit" />
@ -193,6 +201,12 @@ $(function(){
</div>
<script type="text/javascript">
$(function() {
$('.inlineWrapper h3').toggle(function() {
$(this).parent().find('.inlineHidden').slideDown();
}, function() {
$(this).parent().find('.inlineHidden').slideUp();
});
{% for inline in inlines %}
$('#formset_{{inline.prefix}}').formset({
prefix: '{{ inline.prefix }}',