$("#popChapterManage .JS-edit").live("click",function(){
$(this).toggle(function () {
$(this).text("保存");
var input = $(this).parent().siblings(".input");
var inputtext = input.text();
input.html("<input id='txteditchapterName' class='ipt-text grid-12' type='text' value=''>");
input.find("input").val(inputtext);
},
function () {
var chapterId = $(this).attr("aId");
if ($("#txteditchapterName").val() == "") {
alert("章节名称不能为空");
return;
}
$.ajax({
url: "/Teacher/Resource/AddandUpdateChapter",
type: "POST",
async: true,
data: {
Id: chapterId,
ChapterName: $("#txteditchapterName").val(),
ChapterSource: EnumList.CaseSource.Custom,
},
success: function (data) {
alert(data);
GetTheoryChaptertable();
}
});
$(this).text("编辑");
var inputtext = $(this).parent().siblings(".input").find("input").val();
$(this).parent().siblings(".input").html(inputtext);
});
//先触发click,不然第一次失效
$(this).trigger("click");
});
开始没有写
$(this).trigger(“click”);这句,造成每次触发都要点击2次才能实现。