いくつかのコードがあります:
$('.field').live({
mouseenter:
function()
{
old_value=$(this).text();
item_id=$(this).attr('id');
item=$(this).parent('td');
//height=item.attr('height');
height=event.target.parentNode.offsetHeight;
width=event.target.parentNode.offsetWidth;
//$(event.target).replaceWith('<textarea id="current-editor"></textarea>');
//$("#current-editor").height(height-10);
new_value=(old_value=='Not translated') ? '' : old_value;
$(this).empty();
var field="<textarea style='vertical-align: middle; font-family: Helvetica; font-size: 12pt;' id='new_value' name='term'>" + new_value + "</textarea><div id='save_button' class='btn btn-primary' style='float: right' href='#'>Save</div>";
$(this).html(field);
$("#new_value").height(height);
$("#new_value").width(width);
button_id=item_id.split('/')[0];
button_id=button_id.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
$("#"+button_id).show();
},
mouseleave:
function()
{
$(this).empty();
$(this).html(old_value);
$("#"+button_id).hide();
}
}
);
「フィールド」のコード:
echo "<td width='200' style='vertical-align: middle;'><div class='field' id='".$record['translate']['label_value']."/".$record['language_id']."'>".
strip_tags($record['translate']['coalesce(loc.language_value)'])."</div>";
したがって、このコードはテーブルのセルのテキストコンテンツをテキストエリアに変更し、機能します。しかし、テキストエリアの後に「保存」ボタンを追加する必要があり、それも機能します。ボタンは新しい行にあります (テキストエリアの幅は 100% でなければならないため) が、ボタンとテキストエリアが同じ行にある必要があります。教えてください、どうすればいいですか?