0
我正在與圖書館contextmenu選項一起使用表。當用特定的行選擇一個選項時,行ID應顯示在對話內容中。在對話框內容中我有文本框,文本框的值必須傳遞給該方法,我該怎麼做?以下是我目前嘗試過的。如何在對話框內容中獲取Jquery對話框文本框值和<tr>單元格值?
對話內容
<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");
}
}
]
});
你使用任何外部庫..是'contextmenu'外部庫嗎? – 2015-04-17 09:29:21
@gerdi我使用這個爲contextmenu http://medialize.github.io/jQuery-contextMenu/demo.html – Raghu