Can you add to dijit widgets that dojango creates without having to totally overwite them.
(I ask because I want to a开发者_运维知识库dd JS triggers [onChange, onClick] to some widgets)
Yes, there is no need to overwrite the widget. Use dojo.connect in your template to connect the widget event to your desired Javascript.
i.e.
dojo.connect(dijit.byId('id_field'),'onChange',
function(){
//do something
});
Or if you are using dojango forms integration and want to define the trigger with rest of the form. i.e.
from dojango.forms import *
my_field = DateField(
required=True,
help_text="Enter a valid date!",
widget=DateInput(
attrs={
'invalidMessage': 'The date is invalid!',
'class': 'customClass'
'onClick': 'yourFunction()'
}
))
精彩评论