小编the*_*unt的帖子

twig - for循环中的构建数组

是否有可能用值迭代填充树枝数组?

{% for question in questions %}
{% set multipleChoiceArray = [] %}
    {% for multipleChoice in question.multipleChoiceAnswers %}
        {% set multipleChoiceArray = multipleChoiceArray|merge( multipleChoice.answerText )  %}
    {% endfor %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

问题出在这里 multipleChoiceArray|merge(multipleChoice.answerText)

当我尝试传递一个数组,例如使用key = loop.index之类的

{% set multipleChoiceArray = multipleChoiceArray|merge({"loop['index']":"multipleChoice['answerText']"})  %}
Run Code Online (Sandbox Code Playgroud)

它工作但数组包含字符串"["loop ['index']":"multipleChoice ['answerText']"]"

当我尝试传递变量,如:

{% set multipleChoiceArray = multipleChoiceArray|merge({loop.index:multipleChoice.answerText})  %}
Run Code Online (Sandbox Code Playgroud)

例外是:哈希键后面必须跟冒号(:).意外的标记"标点符号"的值"." ("标点符号"预期值":")

所以我无法将"multipleChoice.answerText"值"推"到"multipleChoiceArray"中

有什么提示可行吗?我只想收集所有可能的答案,然后检查答案是否在该阵列中并计算并显示

php arrays symfony twig

20
推荐指数
1
解决办法
3万
查看次数

Angular.js选择整合

我在我的角度视图中选择我要添加所选功能:

<select ng-options="value for value in deutscheBankEvent.dates" ng-init="" ng-model="chosenA" class="chzn-select">
 <option style="display:none" value="">Wählen Sie ein Datum</option>
 </select><br/>
Run Code Online (Sandbox Code Playgroud)

我的控制器:当我在这里注入.chosen函数时,它会清除选项.

function Ctrl($scope,$http) {

  $scope.text = '';
  $scope.user = {name: '', last: '', location: ''};
  $scope.value = 0;
  $scope.sendForm = function (){
       $http.post('/Submit/To/Url', $scope.data).success(function(data) {
           alert('done!');
       });
    };
}
Run Code Online (Sandbox Code Playgroud)

我的页脚:

<g:javascript>
 $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({allow_single_deselect:true});
            jQuery(".adressen1_chzn-select").chosen();jQuery(".adressen0_chzn-select").chosen();
        });
</g:javascript>
Run Code Online (Sandbox Code Playgroud)

我不知道,如何让所选择的工作.内部控制器它清除选项而不适用,其余部分没有任何区别.任何想法赞赏

javascript angularjs jquery-chosen

8
推荐指数
2
解决办法
2万
查看次数

Backbone-forms.js - 如何在github"docs"中呈现示例中的提交按钮

这是骨干表格的代码.现在,我想呈现一个提交按钮来验证我的文本字段和内容,这是记录的,除了如何将提交按钮放入dom.随便投降,无论如何,在我看来这很难找到新手

(function($) {
    var cities = {
        'UK': ['London', 'Manchester', 'Brighton', 'Bristol'],
        'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York']
    };

    //The form
    var form1 = new Backbone.Form({
        schema: {
            country: { type: 'Select', options: ['UK', 'USA'] },
            city: { type: 'Select', options: cities.UK },
            message: { type: 'Text'}
        }
    }).render();

    form1.on('country:change', function(form1, countryEditor) {
        var country = countryEditor.getValue(),
            newOptions = cities[country];
            form1.fields.city.editor.setOptions(newOptions);

    });

    //Add it to the page
    $('body').append(form1.el);
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

html javascript backbone.js backbone-forms

4
推荐指数
1
解决办法
3989
查看次数

grails mail:在localhost上工作的内联映像,而不是在测试环境中

我将内联图像添加到localhost上的邮件中:

inline 'footerImage', 'image/jpg', new File('./web-app/images/mailAssets/suchebottomre.gif').readBytes()
Run Code Online (Sandbox Code Playgroud)

哪个工作正常.当我部署到我的测试环境时,我收到此错误:

Class
java.io.FileNotFoundException
Message
cannot use ./web-app/images/mailAssets/alert_header_pre.png as an attachment as it does not exist
Run Code Online (Sandbox Code Playgroud)

用这个日志:

   Line | Method
->>  331 | inline      in grails.plugin.mail.MailMessageBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     20 | doCall      in de.docinsider.web.NotifierService$_contactUser_closure1
|     39 | sendMail .  in grails.plugin.mail.MailService …
Run Code Online (Sandbox Code Playgroud)

debugging grails localhost html-email

2
推荐指数
1
解决办法
773
查看次数