• <small id='ok4Dw'></small><noframes id='ok4Dw'>

  • <i id='ok4Dw'><tr id='ok4Dw'><dt id='ok4Dw'><q id='ok4Dw'><span id='ok4Dw'><b id='ok4Dw'><form id='ok4Dw'><ins id='ok4Dw'></ins><ul id='ok4Dw'></ul><sub id='ok4Dw'></sub></form><legend id='ok4Dw'></legend><bdo id='ok4Dw'><pre id='ok4Dw'><center id='ok4Dw'></center></pre></bdo></b><th id='ok4Dw'></th></span></q></dt></tr></i><div id='ok4Dw'><tfoot id='ok4Dw'></tfoot><dl id='ok4Dw'><fieldset id='ok4Dw'></fieldset></dl></div>
    1. <legend id='ok4Dw'><style id='ok4Dw'><dir id='ok4Dw'><q id='ok4Dw'></q></dir></style></legend>
    2. <tfoot id='ok4Dw'></tfoot>

          <bdo id='ok4Dw'></bdo><ul id='ok4Dw'></ul>

        symfony 2 twig 访问数组 javascript 索引

        symfony 2 twig access array javascript index(symfony 2 twig 访问数组 javascript 索引)
        <tfoot id='ezrla'></tfoot>

        <small id='ezrla'></small><noframes id='ezrla'>

        <legend id='ezrla'><style id='ezrla'><dir id='ezrla'><q id='ezrla'></q></dir></style></legend>
            <tbody id='ezrla'></tbody>

            1. <i id='ezrla'><tr id='ezrla'><dt id='ezrla'><q id='ezrla'><span id='ezrla'><b id='ezrla'><form id='ezrla'><ins id='ezrla'></ins><ul id='ezrla'></ul><sub id='ezrla'></sub></form><legend id='ezrla'></legend><bdo id='ezrla'><pre id='ezrla'><center id='ezrla'></center></pre></bdo></b><th id='ezrla'></th></span></q></dt></tr></i><div id='ezrla'><tfoot id='ezrla'></tfoot><dl id='ezrla'><fieldset id='ezrla'></fieldset></dl></div>
                  <bdo id='ezrla'></bdo><ul id='ezrla'></ul>
                  本文介绍了symfony 2 twig 访问数组 javascript 索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  知道索引是 javascript 变量是否可以从 twig 数组中获取对象

                  Is it possible to get object from twig array knowing that the index is a javascript variable

                  我的控制器

                  public function showContactModalAction($iduser, $profil) {
                      $em = $this->getDoctrine()->getEntityManager();
                      $contacts = $em->getRepository("LeymaxContactBundle:User")->findBy(array('accesslevel' => 'arch'));
                  
                      return $this->render('LeymaxContactBundle:Default:contactModal.html.twig', array('contacts' => $contacts));
                  }
                  

                  我的树枝

                   $(".fils_zone_livre").on('click', function() {
                          var index=3;
                          var contacts = '{{contacts[index]}}';
                  
                      });
                  

                  我也试过了:

                  var contactArray = '{{contacts|json_encode}}';
                  

                  但我得到了这个回复:

                  [{},{},{},{},{},{}]
                  

                  作为一个空数组

                  推荐答案

                  只需要和你差不多的.

                  但不是

                  var contactArray = '{{contacts|json_encode}}';
                  

                  你应该使用

                  var contactArray = '{{contacts|json_encode|raw}}';
                  

                  希望这会有所帮助.

                  亨内斯

                  这篇关于symfony 2 twig 访问数组 javascript 索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                  Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                  JavaScript radio button confirmation(JavaScript 单选按钮确认)
                  How can I automatically select specific radio buttons with Greasemonkey?(如何使用 Greasemonkey 自动选择特定的单选按钮?)
                  AngularJs. Is it possible to deselect HTML “radio” input by click?(AngularJs.是否可以通过单击取消选择 HTML“收音机输入?)
                  Checking Value of Radio Button Group via JavaScript?(通过 JavaScript 检查单选按钮组的值?)
                  <legend id='DvrPf'><style id='DvrPf'><dir id='DvrPf'><q id='DvrPf'></q></dir></style></legend>

                      <small id='DvrPf'></small><noframes id='DvrPf'>

                      <i id='DvrPf'><tr id='DvrPf'><dt id='DvrPf'><q id='DvrPf'><span id='DvrPf'><b id='DvrPf'><form id='DvrPf'><ins id='DvrPf'></ins><ul id='DvrPf'></ul><sub id='DvrPf'></sub></form><legend id='DvrPf'></legend><bdo id='DvrPf'><pre id='DvrPf'><center id='DvrPf'></center></pre></bdo></b><th id='DvrPf'></th></span></q></dt></tr></i><div id='DvrPf'><tfoot id='DvrPf'></tfoot><dl id='DvrPf'><fieldset id='DvrPf'></fieldset></dl></div>

                        <tfoot id='DvrPf'></tfoot>
                          <tbody id='DvrPf'></tbody>

                            <bdo id='DvrPf'></bdo><ul id='DvrPf'></ul>