Only include select2 assets when needed
from iommi.style import Style
from iommi.asset import Asset
+select2_assets = dict(
+ select2_js=Asset.js(
+ attrs__src='https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js',
+ ),
+ select2_css=Asset.css(
+ attrs=dict(
+ href='https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css',
+ )
+ ),
+)
+
base = Style(
base_template='iommi/base.html',
content_block='content',
),
after=-1,
),
- select2_js=Asset.js(
- attrs__src='https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js',
- ),
- select2_css=Asset.js(
- attrs=dict(
- href='https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/css/select2.min.css',
- )
- ),
),
Form=dict(
template='iommi/form/form.html',
),
multi_choice=dict(
input__template='iommi/form/choice_select2.html',
+ assets=select2_assets,
),
choice_queryset=dict(
input__template='iommi/form/choice_select2.html',
+ assets=select2_assets,
),
date__input__attrs__type='date',
radio=dict(
