[英]How to add an onChange event to Django form fields with field itself as an argument
I'm adding onChange
event on a TextField dynamically. 我正在动态地在TextField上添加
onChange
事件。 The following code explains what I'm doing: 以下代码解释了我在做什么:
fields.widget.attrs['onchange'] = 'execute_function(arg)'
I have add field itself as an argument to javascript function similar to function_name(this)
in django forms. 我已经添加了字段本身作为javascript函数的参数,类似于django表单中的
function_name(this)
。
I want to pass the field itself to execute_function() as an argument to the function. 我想将字段本身传递给execute_function()作为函数的参数。
如果我理解你的问题应该是改变,因为容易arg
来this
:
fields.widget.attrs['onchange'] = 'execute_function(this)'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.