djangosnippets.org: Latest snippets written in JavaScripthttps://djangosnippets.org/languages/javascript/2023-02-24T04:31:40.784315-06:00Django Collapsed Stacked Inlines
2023-02-24T04:31:40.784315-06:00applecathttps://djangosnippets.org/snippets/10947/<p>A simple jQuery javascript that collapses all stacked inline rows for better handling of large inline fieldsets.</p>
<p>It also adds "Show"/"Hide"-buttons for showing/hiding each row, which could be customized and styled using css.</p>
<p><strong>Usage (see below for example):</strong></p>
<p>Include the javascript on your admin page, together with jQuery, and it'll …</p>
Freely redistributableDjango Collapsed Stacked Inlines
2021-01-11T14:31:59.592702-06:00mkarajohnhttps://djangosnippets.org/snippets/10817/<p>A simple jQuery javascript that collapses all stacked inline rows for better handling of large inline fieldsets.</p>
<p>It also adds "Show"/"Hide"-buttons for showing/hiding each row, which could be customized and styled using css.</p>
<p><strong>Usage (see below for example):</strong></p>
<p>Include the javascript on your admin page, together with jQuery, and it'll …</p>
Freely redistributableDynamically adding forms to a formset. OOP version.
2015-05-13T17:46:29.378832-05:00halfnibblehttps://djangosnippets.org/snippets/10484/<p><strong>What It Is</strong></p>
<p>This is a JavaScript-based solution to dynamically add and remove forms in formsets and inlineformsets. It requires jQuery.</p>
<p>Originally based on this Snippet: https://djangosnippets.org/snippets/1389/</p>
<p>I have done a lot of work to make it OO, and am using it in production on pages with multiple inlineformsets, and …</p>
Freely redistributableConvert multiple select for m2m to multiple checkboxes in django admin form
2013-04-12T04:12:29.862262-05:00abidibohttps://djangosnippets.org/snippets/2909/<p>This is a javascript to call in the Media class of the ModelAdmin instance for the model, requires some additional css.</p>
<p>The goal of such approach is that the add related functionality is supported, and works also with the django-mptt model fields.</p>
<p>The new component can support resize functionality, in …</p>
Freely redistributableDjango admin inline ordering - javascript only implementation
2012-12-05T06:32:16.151110-06:00ojhilthttps://djangosnippets.org/snippets/2858/<p>Having spent ages trying out various admin inline ordering packages and examples I found on here and elsewhere I failed to find a single one that did what I was after in the way I wanted or that worked, so I wrote one!</p>
<p>The general idea for this version was …</p>
Freely redistributableGoogle v3 geocoding for Geodjango admin site
2012-10-31T19:26:22.038206-05:00samhaghttps://djangosnippets.org/snippets/2839/<p>This only works with Point geometry.
<a href="http://www.youtube.com/watch?v=gZ7_n177sTE&list=HL1351725584&feature=mh_lolz">video</a></p>
<p>Rename the snippet as gmgdav3.js and save it to template/admin with <a href="http://djangosnippets.org/snippets/2840/">gmgdav3.html</a></p>
<ul>
<li>
<ul>
<li><em>models.py</em>:</li>
</ul>
</li>
</ul>
<p><code>from django.contrib.gis.db import models</code> <br />
<code>class point(models.Model):</code> <br />
<code>address = models.CharField(max_length=100, help_text='Press "Tab" to refresh the map')</code> <br />
<code>longitude = models.FloatField(help_text='WGS84 Decimal Degree. Press "Tab" to refresh the map')</code> <br />
<code>latitude = models.FloatField(help_text='WGS84 …</code></p>
Freely redistributableCitySelector
2012-02-23T06:24:08.007374-06:00JustDelighthttps://djangosnippets.org/snippets/2692/<p>CitySelector is a jquery widget, allowing to pick cities from DB, filled by django_ipgeobase application.
Also it includes widget for django forms, based on mentioned jquery plugin, views and urlconf, required to provide
interaction between widget and DB and middleware, populating request with correspondent location.</p>
<p>Visit https://bitbucket.org/JustDelight/city_selector</p>
Freely redistributableJquery ajax csrf framework for Django
2012-01-23T00:30:21.791394-06:00chriszweberhttps://djangosnippets.org/snippets/2656/<ol>
<li>
<p>Framework to extend the jquery ajax() function to construct post requests that contain a csrf token.</p>
</li>
<li>
<p>The example view used with the framework takes JSON data and returns JSON data containing either:</p>
</li>
<li>"success" with a message and additional dictionary of JSON data to use in the page</li>
<li>
<p>"error" with an …</p></li></ol>
Freely redistributableAdmin actions as buttons instead of a menu [v2]
2011-12-15T23:11:31.033810-06:00itavorhttps://djangosnippets.org/snippets/2630/<p>Add this to your admin change_list.html template to replace the actions drop-down with buttons.</p>
<p>This is a rewritten version of snippet <a href="http://djangosnippets.org/snippets/1931/">1931</a> with Django 1.3 compatibility and cleaner code. Thanks to <a href="http://djangosnippets.org/users/andybak/">andybak</a> for the idea.</p>
Freely redistributableDynamical formsets
2011-11-16T05:28:28.774479-06:00I159https://djangosnippets.org/snippets/2603/<p>If you need dynamical formsets you can use <code>{{ empty_form }}</code> in template and even makeup it.</p>
Freely redistributableAdmin related widget wrapper with edit / delete link (widget js)
2011-10-07T18:09:48.893927-05:00nasphttps://djangosnippets.org/snippets/2564/<p>Here's the python code to produce an admin related widget with the edit and delete link also.</p>
<ul>
<li><a href="http://djangosnippets.org/snippets/2562">RelatedFieldWidgetWrapper</a></li>
<li><a href="http://djangosnippets.org/snippets/2563">related-widget-wrapper.html</a></li>
<li><a href="http://djangosnippets.org/snippets/2564">related-widget-wrapper.js</a></li>
<li><a href="http://djangosnippets.org/snippets/2565">RelatedWidgetWrapperAdmin</a></li>
</ul>
Freely redistributableJavaScript implementation of Python xrange() builtin
2010-12-15T06:01:18.956213-06:00fish2000https://djangosnippets.org/snippets/2287/<p>I don't like not having the <code>range()/xrange()</code> in JavaScript &mdash; particularly when working with <a href="http://documentcloud.github.com/underscore/">Underscore.js</a> and other such libraries &mdash; so I wrote it.</p>
<p>It's not rocket science, but it might help make the world a slightly less annoying place for a couple of people.</p>
Freely redistributableImprove ajax progress bar by jquery extensions
2010-12-11T02:26:53.871758-06:00williamcaihttps://djangosnippets.org/snippets/2286/<p>This snippet in the one to improve the method described in <a href="http://djangosnippets.org/snippets/679/">http://djangosnippets.org/snippets/679/</a>. It uses some jquery extensions to make the task more easier: <strong>jquery.timers.js</strong>, <strong>jquery.progressbar.js</strong>, <strong>jquery.form.js</strong>.</p>
Freely redistributableInitially open collapsable fieldset class in admin
2010-09-17T05:25:12.226136-05:00ralfzenhttps://djangosnippets.org/snippets/2200/<p>It's just an extension for the admin. Replace the collapse.js (collapse.min.js) and use it like this in the admin fieldset option: ´´<strong>'classes': ['collapse', 'open']</strong>´´.
Without the 'open'-class, it will work as usual.
<em>Needs possibly fixing for IE <= 8</em> because IE doesn't support the ´´:not´´ selector.
</p>
Freely redistributableGoogle map on admin address field
2010-08-18T03:47:20.606303-05:00coulixhttps://djangosnippets.org/snippets/2154/<p>Who never wished to have valid address data by showing a little google map with a marker near the address input text ?
Using js only it gets quite easy.</p>
Freely redistributable