Opened 7 years ago

Closed 6 years ago

#11865 closed New feature (duplicate)

Form media lacks support for raw javascript

Reported by: Tareque Hossain Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: form media raw javascript
Cc: tareque@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Form media allows form exclusive css and js to be linked in a systematic fashion. But it lacks support for inclusion of raw javascript that are generated on a per form basis (e.g. initialization of TinyMCE). As a result widget creators have to append javascript to their rendered widget. This translates into bad html practice of including javascript at random points of the HTML file.

This situation can be resolved by adding a third media type: raw_js which can be included at a desired point in the template as {{ form.media.raw_js }}

Attachments (2)

form-media-raw-javascript.patch (1.5 KB) - added by Tareque Hossain 7 years ago.
Suggested changes to django/forms/widget.py
form-media-regression-test.patch (9.4 KB) - added by Tareque Hossain 7 years ago.
Modified regression tests to accommodate changes in form media

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Tareque Hossain

Suggested changes to django/forms/widget.py

Changed 7 years ago by Tareque Hossain

Modified regression tests to accommodate changes in form media

comment:1 Changed 7 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

I'm bikeshedding, but I'm not sure I'm a fan of raw_js as a name. There's nothing particularly 'raw' about it - it's just an embedded script rather thank a linked script.

comment:2 Changed 7 years ago by Tareque Hossain

I would say its a perfectly valid argument! Here are some other names I thought about (given the existing form media titles are 'css' and 'js'):

'inline_js'
'embedded_js'
or just:
'javascript'

comment:3 Changed 6 years ago by Peter Baumgartner

Severity: Normal
Type: New feature

comment:4 Changed 6 years ago by Julien Phalip

Resolution: duplicate
Status: newclosed

Closing as dupe of #13978, which, although newer, also takes care of inline css. I believe it's better to tackle both css and js at once to maintain some consistency.

Note: See TracTickets for help on using tickets.
Back to Top