Hello,
I have a form that use the collapse.js of django admin (outiste django admin). I would like to persist the show/hide fieldsets state when the form is submitted. According to this question this can be achieve with a window.localStorage. What could be an efficient way to use it inside django admin collapse.js ? How should I modify collapse.js to achieve this?
collapse.js
(function($) { $(document).ready(function() { // Add anchor tag for Show/Hide link $("fieldset.collapse").each(function(i, elem) { // Don't hide if fields in this fieldset have errors if ($(elem).find("div.errors").length == 0) { $(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' + i +'" class="collapse-toggle" href="#">' + gettext("Show") + '</a>)'); } }); // Add toggle to anchor tag $("fieldset.collapse a.collapse-toggle").toggle( function() { // Show $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]); return false; }, function() { // Hide $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]); return false; } ); }); })(django.jQuery); You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment