Code

Opened 5 years ago

Closed 3 years ago

#11865 closed New feature (duplicate)

Form media lacks support for raw javascript

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

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by tarequeh

Suggested changes to django/forms/widget.py

Changed 5 years ago by tarequeh

Modified regression tests to accommodate changes in form media

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by tarequeh

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 3 years ago by baumer1122

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 3 years ago by julien

  • Resolution set to duplicate
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.