我发现这几乎正是我想要做的。我正在使用Jeditable我可以让默认设置正常工作。我还能够让上面论坛中的代码正常工作。我相信我的问题是因为我使用的是表格,所以我需要其他东西来选择前一个元素。
这是我的 HTML
<table>
<tr>
<td width="5%"><input class="cat_checkbox" type="checkbox" name='delete_cat[]' value='<?php echo("$cat_data[cat_id]");?>' /></td>
<td width="90%" class="edit_cat_title" id='unique_id'>Category</td>
<td width="5%"><a href="#" class="edit_cat_title_trigger"><img src="images/edit.gif" border="0"></a></td>
</tr>
</table>
这是我的jQuery:
//modify title content on the fly
$('.edit_cat_title').editable('action.php', {
name : 'cat_title',
indicator : 'Saving...',
submit : 'OK',
cancel : 'Cancel',
tooltip:'click to edit',
event : 'edit'
});
//trigger with the click of the edit image
$(".edit_cat_title_trigger").bind("click", function() {
$(this).prev().trigger("edit_cat_title");
});
我知道我可能应该能够弄清楚,我知道我所要做的就是改变$(this).prev().trigger("edit_cat_title");
正确的事情,但我对 Jquery 仍然很陌生。