就地编辑jquery
问题描述:
我用edit-in-place插件:http://arashkarimzadeh.com/jquery/7-editable-jquery-plugin.html就地编辑jquery
我不工作太好了! 我只需要检查一下新文本是否为空。如果是这样,我们必须返回并显示一些错误警报。
代码:
$('.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') })
}
});
可有人请帮助我! - :在发布前
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') });
}
}
答
检查content.current
财产在onSubmit
功能/
答
更改您的onsubmit。
(有也是可用于检查变化content.previous
属性)
例子:
$(document).ready(function() {
$("#div1").editable({
type : 'textarea',
submit : 'OK',
cancel : 'Cancel',
onSubmit : function(content) {
alert(content.current+':'+content.previous);
}
});
});
答
我发现了一个解决方案:
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')});
}
}
它的作品,去展示以前的数据
你能举个例子吗? – william 2009-11-09 11:37:02