V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
linuxs
V2EX  ›  Flask

flask-wtf onclink=js 函数无法传入变量?

  •  
  •   linuxs · Jan 4, 2017 · 3591 views
    This topic created in 3406 days ago, the information mentioned may be changed or developed.
    {% for i in all_info %}
    {{ i.id }}
    {% endfor %}

    <form class="form" id=myforms{{ i.id }} method="POST">
    {{ form.csrf_token }}
    {{ form.hidden_tag() }}
    {{ wtf.form_field(form.serverid,value=i.id) }}
    {{ wtf.form_field(form.publics,value=i.public_ip) }}
    {{ wtf.form_field(form.privates,value=i.private_ip) }}
    {{ wtf.form_field(form.servid,value=i.server_id) }}
    {{ wtf.form_field(form.address,value=i.address) }}
    <div style = "text-align:right;">
    {{ wtf.form_field(form.submit, onclick='chagedata('i.id')')}}
    </div>
    </form>

    onclick='chagedata('i.id')') js 函数无法识别模版{{ i.id }} 变量各种

    在外面加符号,在里面加都不行,
    2 replies    2017-01-08 12:31:44 +08:00
    z4none
        1
    z4none  
       Jan 4, 2017
    {{ wtf.form_field(form.submit, onclick='chagedata('+i.id+')')}} ?
    linuxs
        2
    linuxs  
    OP
       Jan 8, 2017
    @z4none 试过了不行,最后换成 input 方式了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2285 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 15:55 · PVG 23:55 · LAX 08:55 · JFK 11:55
    ♥ Do have faith in what you're doing.