如何添加'collapse'到Django StackedInline [英] How to add 'collapse' to a Django StackedInline
问题描述
以同样的方式,您可以添加类:['collapse']到您的一个ModelAdmin字段中,我希望能够使内联模型管理员可折叠。
In the same way you can add 'classes': ['collapse'] to one of your ModelAdmin fieldsets, I'd like to be able to have an Inline Model Admin be collapsible.
此门票在管理界面中折叠内联相关对象,详细讨论我想要完成什么但是同时我们等待下一个版本,最好的工作是什么?
This ticket, Collapse in admin interface for inline related objects, discusses exactly what I want to accomplish. But in the mean time, what's the best work around while we wait for the next release?
FYI:我想出了一个解决方案,但我觉得更好一个存在我会让投票照顾它。
FYI: I've come up with a solution, but I think a better one exists. I'll let the voting take care of it.
推荐答案
我想出了这个解决方案,使用jQuery在 TabularInline
I came up with this solution using jQuery that works on TabularInline
var selector = "h2:contains('TITLE_OF_INLINE_BLOCK')";
$(selector).parent().addClass("collapsed");
$(selector).append(" (<a class=\"collapse-toggle\" id=\"customcollapser\" href=\"#\"> Show </a>)");
$("#customcollapser").click(function() {
$(selector).parent().toggleClass("collapsed");
});
这篇关于如何添加'collapse'到Django StackedInline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!