diff options
| author | Johannes Hoppe <info@johanneshoppe.com> | 2017-07-20 17:06:30 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-20 11:06:30 -0400 |
| commit | c19b56f633e172b3c02094cbe12d28865ee57772 (patch) | |
| tree | 698bf39231100f9a95ab87aa37b416eb7056e4e0 /docs/topics/forms | |
| parent | f86b6f351d45c366f733c586127251c598dfd541 (diff) | |
Fixed #28377 -- Made combining form Media retain relative asset order.
Thanks Florian Apolloner, Mariusz Felisiak, and Tim Graham for reviews.
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/media.txt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt index 0bdf237a21..b98cc9e740 100644 --- a/docs/topics/forms/media.txt +++ b/docs/topics/forms/media.txt @@ -305,6 +305,42 @@ specified by both:: <script type="text/javascript" src="http://static.example.com/actions.js"></script> <script type="text/javascript" src="http://static.example.com/whizbang.js"></script> +.. _form-media-asset-order: + +Order of assets +--------------- + +The order in which assets are inserted into the DOM if often important. For +example, you may have a script that depends on jQuery. Therefore, combining +``Media`` objects attempts to preserve the relative order in which assets are +defined in each ``Media`` class. + +For example:: + + >>> from django import forms + >>> class CalendarWidget(forms.TextInput): + ... class Media: + ... js = ('jQuery.js', 'calendar.js', 'noConflict.js') + >>> class TimeWidget(forms.TextInput): + ... class Media: + ... js = ('jQuery.js', 'time.js', 'noConflict.js') + >>> w1 = CalendarWidget() + >>> w2 = TimeWidget() + >>> print(w1.media + w2.media) + <script type="text/javascript" src="http://static.example.com/jQuery.js"></script> + <script type="text/javascript" src="http://static.example.com/calendar.js"></script> + <script type="text/javascript" src="http://static.example.com/time.js"></script> + <script type="text/javascript" src="http://static.example.com/noConflict.js"></script> + +Combining ``Media`` objects with assets in a conflicting order results in a +``MediaOrderConflictWarning``. + +.. versionchanged:: 2.0 + + In older versions, the assets of ``Media`` objects are concatenated rather + than merged in a way that tries to preserve the relative ordering of the + elements in each list. + ``Media`` on Forms ================== |
