Opened 15 years ago

Closed 13 years ago

#11865 closed New feature (duplicate)

Form media lacks support for raw javascript

Reported by: Tareque Hossain Owned by: nobody
Component: Forms Version: dev
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: no UI/UX: no

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 15 years ago.
Suggested changes to django/forms/widget.py
form-media-regression-test.patch (9.4 KB ) - added by Tareque Hossain 15 years ago.
Modified regression tests to accommodate changes in form media

Download all attachments as: .zip

Change History (6)

by Tareque Hossain, 15 years ago

Suggested changes to django/forms/widget.py

by Tareque Hossain, 15 years ago

Modified regression tests to accommodate changes in form media

comment:1 by Russell Keith-Magee, 14 years ago

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 by Tareque Hossain, 14 years ago

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 by Peter Baumgartner, 13 years ago

Severity: Normal
Type: New feature

comment:4 by Julien Phalip, 13 years ago

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