开发者

Dojango/Dijit widgets

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()'
        }
    ))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜