【问题标题】:"elem.type is undefined" in typewatchtypewatch 中的“elem.type 未定义”
【发布时间】:2012-05-16 05:59:50
【问题描述】:

我从github页面下载了typewatch文件,把它放在我的vendor/assets/javascripts文件中,并在我的application.js中以正常方式要求它然后我执行以下代码(如github页面所示)

$(function () {
    var options = {
        callback: function(){ alert("changed search text"); },
        wait: 50,
        highlight: true,
        captureLength: 2
    }
    $('#search').typeWatch( options );
});

它根本不起作用。它还破坏了我拥有的backstretch 功能。任何帮助将不胜感激,这变得非常烦人:(

更新:

Firebug 在插件code 的第 38 行给出以下错误:“elem.type is undefined”

【问题讨论】:

  • Chrome 的 WebInspector(或 FF 的 Firebug)是否会在 javascript 控制台中显示任何类型的 javascript 错误?
  • 查看我的更新,感谢回复
  • 在第 36 行输入 console.log(elem),然后说出您在控制台中看到的内容
  • 除了显示 jquery 错误外,它还显示了我尝试键入的表单的 html:
  • 它在您的 HTML 中搜索 type="text"。你正在传递表格。而是将输入字段传递给它

标签: jquery ruby-on-rails ruby-on-rails-3 jquery-plugins typewatch


【解决方案1】:

正如您所报告的,<form id="search" method="get" action="/concerts" accept-charset="UTF-8"> 在 cmets 中显示为 console。这意味着它正在搜索 dom 的 type 属性。并且您正在将form dom 传递给它。相反,您应该传递 input 字段。喜欢$('#search_input_field').typeWatch(options);

【讨论】:

    猜你喜欢
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2021-08-05
    • 1970-01-01
    相关资源
    最近更新 更多