将图标添加到我的编辑窗体中
问题描述:
我正在尝试将图标添加到我的编辑窗体中。该图标按预期显示,但不会对点击事件做出反应。将图标添加到我的编辑窗体中
使用免费的jqGrid 4.13
在colModel
:
{name:'characteristic', index:'characteristic', width:150, editable: true,
editoptions:{rows:'3',cols:'50'}, editrules:{edithidden:true},
formoptions:{rowpos:3, colpos:1,label:"Characteristic:",
elmsuffix: " <img class='genericnotes' src='/QMSWebApp/Images/addnote[3].jpg'>"},
edittype:'textarea'},
在loadComplete:
$('.genericnotes').on("click", function(){
var tControl = this.name;
alert(tControl);
//$('.miscdisplay').load("/QMSWebApp/FirstArticleControllerServlet",
//{lifecycle:"faieditlistdisplay",
//tControl:tControl,
//source:0});
//$('.miscdisplay').show("slide", { direction: "right" }, 1000);
});
答
是错误的使用$('.genericnotes').on("click", function(){...});
的loadComplete
内,因为编辑表单目前不存在。您应该使用例如beforeShowForm
表单编辑回调。免费jqGrid允许指定jqGrid的formEditing
选项中的表单编辑选项/回调(请参阅the wiki article)。因此,你可以通过
formEditing: {
beforeShowForm: function() {
$("#characteristic") // select textarea#characteristic
.next(".genericnotes")
.on("click", function() {
alert("Click");
});
}
}
答
尝试var tControl = $(this).attr("name");
@ OlegThanks,伟大的作品。 –
@SteveDyke:不客气! – Oleg