我正在使用库contextmenu选项。当使用特定行选择一个选项时,行ID应显示在对话框内容中。在对话框内容中我有文本框,文本框的值必须传递给方法我该怎么办?以下是我目前的尝试。
对话内容
<div id="dialogbox" >
<p>Enter Driver Message for <span id="bus"></span> </p>
<input type="text" id="msg" name="msg">
</div>
上下文菜单选项
$(function(){
$.contextMenu({
selector: '.context-menu-one',
/* trigger: 'hover',
delay: 500, */
autoHide: true,
callback: function(key, options) {
var message = "global: " + key;
var busId = $(this).closest("tr").find('td:eq(0)').text(); // table row value
//document.getElementById("bus").innerHTML=busId;
$('#bus').text(busId); //Here I am setting to diloug content
},
items: {
"DMsg": {
name: "Send Driver Message",
icon: "edit",
// superseeds "global" callback
callback: function(key, options) {
var busId = $(this).closest("tr").find('td:eq(0)').text();
openDriverMsgDiloug(busId);
}
},
function openDriverMsgDiloug(busId)
{
$('#dialogbox').dialog('open');
}
对话框
$("#dialogbox").dialog({
autoOpen:false,
title: "Driver Message",
modal:true,
buttons: [
{
text: "Send",
icons: {
primary: "ui-icon-heart"
},
click: function() {
var msg= // have to get the value of textbox in diloug
sendToClient(busId,msg);
$( this ).dialog( "close" );
}
},
{
text: "Close",
icons: {
primary: "ui-icon-heart"
},
click: function() {
$( this ).dialog( "close" );
}
}
]
});