单击 btn 时如何显示表单(来自 Twig 渲染器)
How can I display a form (from Twig render), when I click on btn
现在,我尝试在我的应用程序中使用 FosUserBundle...
我想集成登录表单,在我点击登录按钮时显示在我的视图中。
如何使用树枝方法,例如:
{% render url('fos_user_security_login') %}
有 jquery click() 事件?
示例:
layout.html.twig(当我没有点击登录按钮时)
<html>
<header>...</header>
<body>
<section>...</section>
<section>...</section>
<section>...</section>
</body>
<footer>...</footer>
</html>
layout.html.twig(当我点击登录按钮时)
<html>
<header>...</header>
<body>
<section>...</section>
<section>...</section>
<section>...</section>
</body>
<footer>...</footer>
<!--{% render url('fos_user_security_login') %}-->
<div id="login">
<form>
<input></input>
<input></input>
<input></input>
</form>
</div>
</html>
我要混合
var = {% render url('fos_user_security_login') %}
和
$( "#login" ).append( var )...
像这样...
谢谢你!
我觉得应该把页面内容从头开始,隐藏,点击后显示link。
但是如果你想动态添加它,你可以使用原型:
在您的登录按钮中输入 属性
data-prototype="{{ _self.login_form_prototype()|e }}"
在其他块之外的某个地方,实现原型:
{% macro login_form_prototype() %}
<form>
<input></input>
<input></input>
<input></input>
</form>
{% endmacro %}
在 Javascript 中,在点击事件中使用这个:
var prototype = $('#login-btn').data('prototype');
$( "#login" ).html( prototype );
如果您将登录表单作为变量,则可以将其作为参数发送给宏。
希望我明白你想做什么。
现在,我尝试在我的应用程序中使用 FosUserBundle...
我想集成登录表单,在我点击登录按钮时显示在我的视图中。
如何使用树枝方法,例如:
{% render url('fos_user_security_login') %}
有 jquery click() 事件?
示例:
layout.html.twig(当我没有点击登录按钮时)
<html>
<header>...</header>
<body>
<section>...</section>
<section>...</section>
<section>...</section>
</body>
<footer>...</footer>
</html>
layout.html.twig(当我点击登录按钮时)
<html>
<header>...</header>
<body>
<section>...</section>
<section>...</section>
<section>...</section>
</body>
<footer>...</footer>
<!--{% render url('fos_user_security_login') %}-->
<div id="login">
<form>
<input></input>
<input></input>
<input></input>
</form>
</div>
</html>
我要混合
var = {% render url('fos_user_security_login') %}
和
$( "#login" ).append( var )...
像这样...
谢谢你!
我觉得应该把页面内容从头开始,隐藏,点击后显示link。
但是如果你想动态添加它,你可以使用原型:
在您的登录按钮中输入 属性
data-prototype="{{ _self.login_form_prototype()|e }}"
在其他块之外的某个地方,实现原型:
{% macro login_form_prototype() %}
<form>
<input></input>
<input></input>
<input></input>
</form>
{% endmacro %}
在 Javascript 中,在点击事件中使用这个:
var prototype = $('#login-btn').data('prototype');
$( "#login" ).html( prototype );
如果您将登录表单作为变量,则可以将其作为参数发送给宏。
希望我明白你想做什么。