题
我使用地面插件: http://arashkarimzadeh.com/jquery/7-edialitable-jquery-plugin.html
我做得不好!我只需要一些东西来检查新文本是否为空。如果是,我们必须返回并显示一些错误警报。
编码:
$('.name').editable({
submit:'Gem',
cancel:'Fortryd',
onSubmit: function(content){
$.post('/admin/ajax/products/edit_category/',{ category_name:$(this).text(),category_id: this.parent().attr('id') })
}
});
有人可以帮帮我吗! : - //
解决方案
检查 content.current
属性 onSubmit
发布前的功能。
(还有一个 content.previous
可用于检查更改的属性)
例子:
$(document).ready(function() {
$("#div1").editable({
type : 'textarea',
submit : 'OK',
cancel : 'Cancel',
onSubmit : function(content) {
alert(content.current+':'+content.previous);
}
});
});
其他提示
更改您的贵宾:
onSubmit: function(content){
if ($(this).val()=='') {
alert("can't be blank");
} else {
$.post('/admin/ajax/products/edit_category/',{ category_name:$(this).text(),category_id: this.parent().attr('id') });
}
}
我找到了一个解决方案:
function end(content){
if (content.current == '') {
$(this).text(content.previous);
}else{
$.post('/admin/ajax/products/edit_category/',{ category_name:$(this).text(),category_id: this.parent().attr('id')});
}
}
它的作品,并显示先前的数据
不隶属于 StackOverflow