2π
β
This is not included by default (afaik..).
If you just need this once, is possible to use crispy-forms HTML Layout Object
HTML('<input type="button" name="Save" onclick="do_whatever" />')
What do you then dislike using jQuery? You could handle this rather easy and generic, using something like:
$('form :submit.ajax_submit').live('click', function(e) {
e.preventDefault();
var my_form = $(this).parents('form');
// do whatever
alert(my_form.attr('id'));
alert(my_form.attr('action'));
});
and then just pass the class:
Submit('save', 'save', css_class='ajax_submit')
π€ohrstrom
5π
Are you certain that Button will not take onclick in its kwargs?
I just added an onclick="javascript here"
to a Submit()
element and it displayed fine.
I also peered a bit at the underlying code, and I think all inputs by default flatten the kwargs that arenβt popped because of special use (i.e. template), and pass those through into the rendered HTML. This may be new since April β12 (when originally posted), but it currently seems to be as simple as the following:
self.helper.add_input(Button('back', "Back", css_class='btn', onclick="alert('Neat!');"))
π€jlovison
- [Django]-Django flatpages and images
- [Django]-Django not working with supervisor, getting [Errno 88] Socket operation on non-socket
Source:stackexchange.com