PlaceHolder属性不适用于SimpleTextarea和ValidationTextBox的mixin

时间:2016-01-08 17:38:23

标签: javascript dojo

您好我在Stack Overflow上使用了example来创建自定义ValidationTextArea小部件。我遇到的问题是新的自定义窗口小部件不显示placeHolder属性。

自定义小部件的代码是:

define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"],
function (declare, lang, SimpleTextarea, ValidationTextBox) {

        return declare('dijit.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], {
            constructor: function (params) {
                this.constraints = {};
                this.baseClass += ' dijitValidationTextArea';
            },
            templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>"
        })
    })

我的小部件的标记是:

<textarea data-dojo-type="Scripts/ValidationTextArea"
                                  data-dojo-attach-point="taProjectDescription" style="width:425px; height:75px"
                                  required='true'
                                  placeHolder="max 3000 characters"
                                  data-dojo-props="trim:true,maxLength:'3000'"></textarea>

我需要添加到自定义窗口小部件代码中以使其显示placeHolder吗?我在Chrome上看这个

由于

1 个答案:

答案 0 :(得分:1)

您必须将占位符传递给新模板..

templateString:"<textarea ${!nameAttrSetting} 
  data-dojo-attach-point='focusNode,containerNode,textbox' 
  autocomplete='off' 
  placeHolder='${placeHolder}'>
  </textarea>"