[英]js method in Application.js not being called
I put the following method in my application.js file. 我将以下方法放入了application.js文件。
var formhandler = function() {
var submit, isSubmit = false;
submit = function(){
// flop and return false once by the use of operator order.
return isSubmit != (isSubmit = true);
};
return {
submit: submit
};
}(); // <-- use direct invcation to keep the internal variables "static"
It works fine if I write it directly in the header section of the form. 如果我直接将其写在表单的标题部分中,它将很好地工作。 However when I put it in the application.js file it is not being called or found.
但是,当我将它放在application.js文件中时,它没有被调用或找到。
How should I call functions that are in applcation.js. 我应该如何调用applcation.js中的函数。
Also I have the following in the header of the layout. 我在布局的标题中也有以下内容。
<%= javascript_include_tag :all, :cache => true, :recursive => true %>`enter code here`
I don`t fully understand your question,so I may be wrong, but as a remark: 我不完全理解您的问题,所以我可能是错的,但请注意:
here you always return false: 在这里,您总是返回false:
return isSubmit != (isSubmit = true);
I think it should be 我认为应该
return isSubmit != (isSubmit == true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.