开发者

Dojango/Dijit widgets

开发者 https://www.devze.com 2023-04-06 10:58 出处:网络
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

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

精彩评论

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

关注公众号