在jquery-mobile中有一段代码是这样的
var onTextChanged = function(){
if($("#account").val() != "" && $("#password").val() != ""){
$("#loginBtn").button("enable");//但是每次执行到这里,总会出现“cannot call methods on button prior to initialization; attempted to call method 'disable'”的错误,找了半天也不知道哪里错了。
}else{
$("#loginBtn").button("disable");
}
}
$("#account").bind("input",onTextChanged);
$("#password").bind("input",onTextChanged);
问题已经写在了注释中,上网查了查,有人说,动态生成控件会导致这个错误,但是我这两个控件不是动态生成的,都是已经写死在了html中。
有经验的帮忙给看看,谢谢。
http://stackoverflow.com/questions/17874259/jquery-mobile-error-cannot-call-methods-on-button-prior-to-initialization-att