I know how to do this:
class CalendarWidget(forms.TextInput):
class Media:
js = ('animations.js', 'actions.js')
But then i get something like: "<script type="text/javascript" src="http://media.example.com/animations.js">"
What I want is something like this:
<script>callMYFunction(sdf); </script>
By doing something like this:
class CalendarWidget(forms.TextInput):
class Media:
js = (callMYFunction(sdf),)
But I can't get this do work.. Any ideas?
You'll have to manually add that to the render method of your Widget.
class CalendarWidget(forms.TextInput):
def render(self, name, value, attrs=None):
out = super(CalendarWidget,self).render(name, value, attrs=attrs)
return out + '<script type="text/javascript">callMyFunction(sdf)</script>'
class Media:
js = ('animations.js', 'actions.js') # callMyFunction should be defined in one of these
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With