如何在TVJS中获取TVML textField的节点和键盘参考? [英] How to get the node and keyboard reference of TVML textField in TVJS?

查看:205
本文介绍了如何在TVJS中获取TVML textField的节点和键盘参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人在这里问了同样的问题你好吗?从TVML textField中获取价值?但没有解释完整的答案,我的评论已被编辑,建议我提出一个全新的问题。这是...



任何人都可以帮助理解如何最好地获得对 textField 节点的引用及其来自TVML的键盘价值?现在,我在 Presenter.js 中使用以下代码,一旦用户点击<,就可以到达 textField 显示表格&的模板中的code>完成按钮键盘,但仍然得到


ITML:undefined不是对象(评估'textField.getFeature') - ... / js / Presenter我使用 getFeature(键盘)

  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; //应该给我< formTemplate> element
var children = formTemplate.childNodes;
var textField = children [1]; //这是< formTemplate>中的第二个元素< banner>< / banner>< textField>< / textField> ...
var keyboard = textField.getFeature(Keyboard); //这会引起ITML错误...
...........................






更新:



我发现通过查看通过遍历XML DOM访问元素的解决方案:

  var formTemplate = ele.parentNode.parentNode; //你的formTemplate按钮
var children = formTemplate.childNodes;
var textField = children.item(1); //用模板​​中textField元素的索引替换1
var keyboard = textField.getFeature(Keyboard); //获取textField的Keyboard元素
var userValue = keyboard.text; //用户在Apple TV键盘上输入的值


解决方案

从文档的根目录开始怎么样?使用 getElementsByTagName getElementByTagName getElementById 访问 textField

  var doc = navigationDocument.documents [navigationDocument.documents.length- 1]; 
var textField = doc.getElementByTagName(textField)

var value = textField.getFeature(Keyboard)。text;


Someone asked the same question here How do you get the value from a TVML textField? but didn't explain the full answer and my comment there was edited, suggesting me to ask a brand new question. Here it is...

Can anyone help understand how to best get a reference to the textField node and its keyboard value from TVML? Right now I'm using this code below in Presenter.js to get to the textField once the user clicks the Done button in the template displaying the form & keyboard, but still get

ITML : undefined is not an object (evaluating 'textField.getFeature') - .../js/Presenter.js

when I use 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...  
    ...........................


UPDATE:

I found the solution by looking into accessing elements by traversing 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 

解决方案

How about starting at the document's root? Use getElementsByTagName, getElementByTagName or getElementById to access the textField.

var doc = navigationDocument.documents[navigationDocument.documents.length-1];
var textField = doc.getElementByTagName("textField")

var value = textField.getFeature("Keyboard").text;

这篇关于如何在TVJS中获取TVML textField的节点和键盘参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆