未捕获的TypeError:无法读取属性' next_page'未定义的

时间:2014-10-15 21:17:41

标签: javascript php jquery

我在网站上为客户工作,这段代码过去一直在运作,但突然间不再有效。没有人触及核心代码,我甚至不确定在哪里寻找解决方案。

我们使用Docebo(LMS),在测试中我们要求学生选择答案,然后才能点击"下一个问题"。如果他们没有选择答案,该按钮将变灰并且无法点击。我相信框架正在使用YUI库。

我没有得到" Uncaught TypeError:无法读取属性' next_page'未定义"错误,直到我选择答案。一旦发生错误,该按钮就不起作用。

Chrome的控制台指向这段代码......

function controlTotQuestion()
{
var info = YAHOO.util.Dom.get('answer_info');
if(tot_question == 0)
{
setTimeout(function() {
  if(YAHOO.buttonObjects.next_page)
    YAHOO.buttonObjects.next_page.set('disabled', false);
  if(YAHOO.buttonObjects.show_result)
    YAHOO.buttonObjects.show_result.set('disabled', false);
  if(info)
    info.style.display = 'none';
}, 0);

}
else
{
setTimeout(function() {
  if(YAHOO.buttonObjects.next_page)
    YAHOO.buttonObjects.next_page.set('disabled', true);
  if(YAHOO.buttonObjects.show_result)
    YAHOO.buttonObjects.show_result.set('disabled', true);
  if(info)
    info.style.display = 'block';
}, 0);
}
}

非常感谢任何帮助!

谢谢!

1 个答案:

答案 0 :(得分:2)

它正在尝试阅读next_page的属性YAHOO.buttonObjects。因此YAHOO.buttonObjects未定义。换句话说,无论YAHOO是什么,它都不再具有名为buttonObjects的元素。 YAHOO是外部库吗?如果是,请检查他们是否已删除buttonObjects功能。