【发布时间】:2018-06-04 16:47:27
【问题描述】:
我在烧瓶中有这样的表格:
class form1(Form):
count1=IntegerRangeField('count1')
count2=IntegerRangeField('count2')
class form2(Form):
Incoming=FormField(form1)
Outgoing=FormField(form1)
在模板中,我使用一个循环来渲染字段,该循环根据字段类型运行一个宏:
{% macro render(form) %}
<script type='text/javascript'>
function updateRangeInput(elem) {
$(elem).next().val($(elem).val());
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
{% if field.type in ["IntegerRangeField","FormField"] %}
{{field.name}}
{{field(min=0, max=25, oninput="updateRangeInput(this)")}}
<output><script> document.write() </script > </output>
{% else %}
</body>
{% endmacro %}
宏不显示为 IntegerRangeFields(宏)选择的滑块整数,但字段会在页面上呈现。如何让 IntegerRangeFields 底层 FormFields 应用宏?
注意:如果我直接在 FormField 的地方使用 IntegerRangeFields,它可以工作。
【问题讨论】:
标签: javascript html flask macros flask-wtforms