我有一个基本信息div,当用户点击编辑按钮时,我有一个编辑按钮,这个基本信息div将被转换为表格。我正在使用Jeditable!为了这项工作。但问题是,当用户点击编辑按钮时,我的JavaScript函数被调用,然后对于可编辑我必须单击该字段进行编辑但我希望只需一次单击表单就可以看到我不必去并单击每个字段。 javascript方法的代码如下所示
// alert('ready');
alert("I Got That All!!!");
$('#name1').editable(' '
);
$('#name1').editable('enable');
$('#BG1').editable(' ',
{
data: " {'1':'O+','2':'O-','3':'A+','4':'A-','5':'B+','6':'B-','7':'AB+','8':'AB-','selected':'1'}",
type: 'select'
}
);
$('#BG1').editable('enable');
$('#DOB2').editable('');
$('#DOB2').editable('enable');
$('#MS1').editable(' ',
{ data: "{'1':'Single','2':'Married','3':'Engaged','selected':'1'}",
type: 'select'
}
);
答案 0 :(得分:1)
您需要将editable附加到自定义event
,例如custom.editable
,然后在用户点击编辑按钮时触发相同的事件(比如它的ID是“#edit”)
$('#edit').on('click', function() {
$('.editable').trigger('custom.editable');
}
并配置您的可编辑区域:
$('.editable').editable('... path ...', {
event: 'custom.editable'
... more config ...
}
看到这个小提琴:http://jsfiddle.net/f2akB/