X-editable with parsley 调用 ajax 两次
X-editable with parsley call ajax twice
我有这个代码:
$.fn.editable.defaults.mode = 'inline';
var editable = $('.x-editable').editable({
send: 'always',
validate: function() {
var form = editable.next().find('form');
if (!form.parsley().isValid()) {
return true;
}
}
});
editable.on('shown', function () {
var form = editable.next().find('form');
form.parsley();
});
和html:
<a class="x-editable toggle-content editable editable-pre-wrapped editable-click" href="#" data-toggle-limit="110" data-toggle-limit-padding="10" data-custom-params="{"inLaunchId":1489,"inActivitySummaryId":71962900}" data-disabled="false" data-emptytext="Add a comment" data-escape="true" data-name="inComment" data-placeholder="" data-tpl="<textarea maxLength="4000" data-parsley-pattern="^\d+$" data-popover="<p>Max length: <b>4000</b></p>"></textarea>" data-type="textarea" data-url="submitURL" data-value="text">text</a>
并且由于未知原因 ajax 请求发送了两次,有人知道为什么吗?如何解决这个问题?这里是jsFiddle
由于您使用的是可编辑的表单,而欧芹仅用于验证 - 快速修复将禁用欧芹提交表单。在这种情况下 - 字段将由 bootstrap editable.
提交
$.fn.editable.defaults.mode = 'inline';
var editable = $('.x-editable').editable({
send: 'always',
validate: function() {
var form = editable.next().find('form');
if (!form.parsley().isValid()) {
return true;
}
}
});
editable.on('shown', function () {
var form = editable.next().find('form');
form.parsley().on('form:submit', function() {
return false; // Don't submit form
});;
});
我有这个代码:
$.fn.editable.defaults.mode = 'inline';
var editable = $('.x-editable').editable({
send: 'always',
validate: function() {
var form = editable.next().find('form');
if (!form.parsley().isValid()) {
return true;
}
}
});
editable.on('shown', function () {
var form = editable.next().find('form');
form.parsley();
});
和html:
<a class="x-editable toggle-content editable editable-pre-wrapped editable-click" href="#" data-toggle-limit="110" data-toggle-limit-padding="10" data-custom-params="{"inLaunchId":1489,"inActivitySummaryId":71962900}" data-disabled="false" data-emptytext="Add a comment" data-escape="true" data-name="inComment" data-placeholder="" data-tpl="<textarea maxLength="4000" data-parsley-pattern="^\d+$" data-popover="<p>Max length: <b>4000</b></p>"></textarea>" data-type="textarea" data-url="submitURL" data-value="text">text</a>
并且由于未知原因 ajax 请求发送了两次,有人知道为什么吗?如何解决这个问题?这里是jsFiddle
由于您使用的是可编辑的表单,而欧芹仅用于验证 - 快速修复将禁用欧芹提交表单。在这种情况下 - 字段将由 bootstrap editable.
提交$.fn.editable.defaults.mode = 'inline';
var editable = $('.x-editable').editable({
send: 'always',
validate: function() {
var form = editable.next().find('form');
if (!form.parsley().isValid()) {
return true;
}
}
});
editable.on('shown', function () {
var form = editable.next().find('form');
form.parsley().on('form:submit', function() {
return false; // Don't submit form
});;
});