Cha*_*rma 7 jquery google-chrome ruby-on-rails
我正在尝试在1事件上添加一个确认,它在Firefox上运行,但在chrome上不起作用,之前它也在chrome上运行,但现在不行。
现在确认框出现了,但是很快消失了,它闪烁了。
下面是此代码:
$('.job_form').on('submit', function(e) {
if (!confirm("If this job is posted to more than 1 person, it will go to the first person that accepts it.")) {
e.preventDefault();
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
<%= form_with(model: job, html: {"data-parsley-validate" => '', class: 'job_form'}, local: true) do |f| %>
// html fields
<%= render partial: 'form2', locals: {f: f} %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
下面是form2
//html fields
<div id="isAllDiv"></div>
<div class="col-md-12 text-center">
<%= f.submit 'Post Job', class: 'btn btn-primary signin-btn' %>
//html code with other fields
Run Code Online (Sandbox Code Playgroud)
执行$ ._ data($(“。job_form”)[0],“ events”);的输出;
* {submit: Array(2), click: Array(1)}
* click: Array(1)
* 0:
* data: undefined?guid: 19?handler: ƒ (t)
* guid: 19?arguments: (...)?caller: (...)?length: 1?name: ""?prototype: {constructor: ƒ}?__proto__: ƒ ()?[[FunctionLocation]]: parsley.min.self-78b…b2ddab.js?body=1:17?[[Scopes]]: Scopes[3]?
* namespace: "Parsley"?needsContext: false?origType: "click"?selector: "input[type="submit"], button:submit"?type: "click"?__proto__: Object?
* delegateCount: 1?length: 1?__proto__: Array(0)?
* submit: Array(2)
* 0:
* data: undefined?guid: 18?handler: ƒ (t)?namespace: "Parsley"?needsContext: undefined?origType: "submit"?selector: undefined?type: "submit"?__proto__: Object?
* 1:
* data: undefined?guid: 42?handler: ƒ (e)?namespace: ""?needsContext: undefined?origType: "submit"?selector: undefined?type: "submit"?__proto__: Object?
* delegateCount: 0?length: 2?__proto__: Array(0)?
* __proto__:
* constructor: ƒ Object()?hasOwnProperty: ƒ hasOwnProperty()?isPrototypeOf: ƒ isPrototypeOf()?propertyIsEnumerable: ƒ propertyIsEnumerable()?toLocaleString: ƒ toLocaleString()?toString: ƒ toString()?valueOf: ƒ valueOf()
* arguments: (...)?caller: (...)?length: 0?name: "valueOf"?__proto__: ƒ ()?[[Scopes]]: Scopes[0]?
* __defineGetter__: ƒ __defineGetter__()?__defineSetter__: ƒ __defineSetter__()?__lookupGetter__: ƒ __lookupGetter__()?__lookupSetter__: ƒ __lookupSetter__()?get __proto__: ƒ __proto__()?set __proto__: ƒ __proto__()?
Run Code Online (Sandbox Code Playgroud)
我进行了以下更改以使其正常工作。1.我已将提交按钮更改为锚标记:
<%= link_to 'Post Job', '#', id: 'submit_job' %>
然后,我处理了它的点击事件并在其中添加了超时:
$("#submit_job").on('click', function(){
if ($('.job_form').parsley().validate()){
setTimeout(function(){
if (!confirm("If this job is posted to more than 1 person, it will go to the first person that accepts it.")) {
e.preventDefault();
return false;
}
$('.job_form').submit();
}, 300);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
345 次 |
| 最近记录: |