0
那麼,基本上我有以下代碼(我使用jQuery)。我使用下面的代碼通過ajax post動態更新字段。所有工作正常,但當我使用代碼動態生成內容與多個輸入字段時,該代碼不起作用。我使用「活」,但似乎這不起作用。任何解決方案提前致謝。Ajax編輯框問題
我的HTML代碼:
<span class="text_wrapper">
<span class="imageInf"><a href="tag/1235">1235</a></span>
<a href="javascript:;" class="edit_link" title="Add/Edit">
<img src="i/edit.png" class="middle">
</a>
</span>
<span class="edit" style="display:none"><input type="text" class="editbox" name="mediatags" value="1235"></span>
我的JavaScript代碼:
//ajax edit box
$(document).ready(function()
{
//Edit link action
$('.edit_link').live("click", function()
{
$('.text_wrapper').hide();
var data=$('.text_wrapper').html();
$('.edit').show();
$('.editbox').html(data);
$('.editbox').focus();
});
//Mouseup textarea false
$(".editbox").mouseup(function()
{
return false
});
//Textarea content editing
$(".editbox").live("change", function()
{
$('.edit').hide();
var boxval = $(".editbox").val();
var dataString = 'data='+ boxval;
$.ajax({
type: "POST",
url: "editPicName.php",
data: dataString,
cache: false,
success: function(html)
{
$('.text_wrapper').html(boxval);
$('.text_wrapper').show();
}
});
});
//Textarea without editing.
$(document).mouseup(function()
{
$('.edit').hide();
$('.text_wrapper').show();
});
});