aRkadeFR
unread,Feb 13, 2015, 11:02:31 AM2/13/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hello everyone,
I'm using FormSet in order to add multiple object at once on
a view. To have a more user friendly approach, I created a
'my.formset.js' file and I need to include a 'jquery.formset.js' lib
to add/remove row of the formset (client side) and edit the
formset management information.
My idea to resolve this problem was to include these two
javascript media file everytime I'm using a formset.
A bit like every media js file for widgets :)
So my first attempt was something like that:
```
class BaseFormSet(BaseInlineFormSet):
class Media:
js = ("my.formset.js", "jquery.formset.js", )
```
but this doesnt render these js files with formset.media.render_js().
My second attempt was:
```
formset.media.add_js( ["my.formset.js", "jquery.formset.js", ])
```
My last attempt:
```
form = formset.forms[0]
formset.forms[0].fields[form.fields.keys()[0]].media.add_js(["my.formset.js",
"jquery.formset.js", ])
```
Still not working cause the .media._js is regenerating the media js
files.
The only solution so far I have, provided by @tbaxter, is to
include all my js files in all my application, and initialize/use
the formset/widgets javascript only on certain condition.
I don't like the idea of including my js application wide. It's
gonna overload all my pages for nothing (my js files are
completely standalone) when there is no FormSet.
Can I have your tought on this probleme, and what solution
you have in mind?
Thank you,