我正在尝试制作一个表单,因此当用户单击按钮时它将提交,但问题是即使我没有按下提交按钮,它也会继续运行。这是我的代码
$(function () {
var url, container, form,
View = {
init: function () {
container = $('.container');
form = $('.search#form');
console.log(form);
View.loadViews();
$(document).on('submit', '#form', View.findView());
},
findView: function () {
console.log('helllo');
return false;
},
loadViews: function (view) {
$(container).load('search.html');
}
};
View.init();
});
在上面的代码中,该行$(document).on('submit', '#form', View.findView());
一直调用 findView() 方法,而我想在用户单击提交按钮时调用它。我怎样才能解决这个问题?