誰かがここで同じ質問をしましたどうすれば TVML textField から値を取得できますか? しかし、完全な回答を説明しておらず、そこにある私のコメントが編集されたため、まったく新しい質問をするよう提案されました。ここにあります...
textField
TVML からノードとそのキーボード値への参照を取得する最良の方法を理解できる人はいますか? 現在、以下のコードを使用してPresenter.js
、textField
ユーザーがDone
フォームとキーボードを表示するテンプレートのボタンをクリックすると、
ITML : undefined はオブジェクトではありません (「textField.getFeature」を評価します) - .../js/Presenter.js
私が使用するときgetFeature("Keyboard")
:
load: function(event) {
var self = this,
ele = event.target,
templateURL = ele.getAttribute("template"),
presentation = ele.getAttribute("presentation"),
videoURL = ele.getAttribute("videoURL");
if (templateURL && (event.type == "select")) {
var formTemplate = ele.parentNode.parentNode; // that should give me <formTemplate> element
var children = formTemplate.childNodes;
var textField = children[1]; // which is the second element in <formTemplate><banner></banner><textField></textField>...
var keyboard = textField.getFeature("Keyboard"); // this raises the ITML Error...
...........................
アップデート:
XML DOM をトラバースして要素にアクセスすることを調べて、解決策を見つけました。
var formTemplate = ele.parentNode.parentNode; // your formTemplate button
var children = formTemplate.childNodes;
var textField = children.item(1); // replace "1" with the index of "textField" element in your template
var keyboard = textField.getFeature("Keyboard"); // get the textField's Keyboard element
var userValue = keyboard.text; // the value entered by the user on the Apple TV keyboard