カスタム プレースホルダー コントロールを作成しようとしています。コードの抜粋は次のとおりです。
(function () {
var Placeholder = WinJS.Class.define(function ctor(elem, options) {
this.element = elem || document.createElement('div');
this.element.winControl = this;
WinJS.UI.setOptions(this, options);
this.init();
},
{
element: {
get: function () {
return this._element;
},
set: function (value) {
this._element = value;
}
},
placeholder: {
get: function () {
return this._placeholder;
},
set: function (value) {
this._placeholder = value;
this._placeholderElement.textContent = value;
}
},
placeholderClass: {
get: function () {
return this._placeholderClass;
},
set: function (value) {
this._placeholderClass = value;
this._placeholderElement.classList.add(value);
}
},
_placeholderElement: null,
init: function () {
this._addPlaceholder();
},
_addPlaceholder: function () {
/* Code to add placeholder. */
}
});
WinJS.Namespace.define("ControlX", { Placeholder: Placeholder });
})();
私はこの方法でhtmlでこのコントロールを使用しようとしています:
<div data-win-control="ControlX.Placeholder" data-win-res="{winControl:{placeholder:'resHeight'}}"><input type="text"/></div>
属性を使用してプレースホルダー値を設定するとdata-win-res
、例外が発生します。
「未定義または null 参照のプロパティ 'placeholder' を設定できません」
この記事によると: WinJS コントロールをローカライズする方法では、リソース文字列を winControl 属性にもバインドできます。
私は何を間違っていますか?
リソース文字列を winControl プロパティにバインドする他の方法はありますか?