Symfony2的最佳实践:重定向或触发服务器端的Ajax的对话 [英] Symfony2 best practice: redirect or trigger ajax-dialog from serverside

查看:95
本文介绍了Symfony2的最佳实践:重定向或触发服务器端的Ajax的对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Symfony2的项目与一些Ajax的对话。现在,我发现,这将是第一次直接登录系统后,执行其中的一个有帮助的,所以它不能被忘记。

I have a symfony2-project with some ajax-dialogs. Now I found out, that it would be helpful to execute one of them directly after first login, so that it can't be forgotten.

什么是我们的最佳做法? 是否有比发送一些与生成的网页(隐藏)标签,强制客户方阿贾克斯立即做调用任何其他方式?

What is the best practice for this? Is there any other way than sending some kind of (hidden) tag with the generated page that forces the clientside-ajax to do that call immediately?

推荐答案

该解决方案应该仍然是一个重定向。其中,登记后,用户被重定向的动作应该检查用户是否有添加的项目,如果没有,显示对话框。

The solution should still be a redirect. The action where the user after the registration is redirected should check if the user has items added and if not, show the dialog.

如果您使用的是jQuery UI的对话框是pretty的方便。

If you are using jQuery UI dialogs it is pretty easy.

// your temaplate (i use twig syntax)
{% if mustShowDialog %}
<script>
  $("#dialog").dialog("open");
</script>
{% endif %}

您可以看到一个演示在jQuery UI的演示页面,

You can see a demo for that in the jQuery UI demo page

这篇关于Symfony2的最佳实践:重定向或触发服务器端的Ajax的对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆