2013-04-11 56 views
0

我正在使用JQuery對話框來提醒用戶他們即將刪除一個項目。我需要在對話框中放置註釋文本框,然後使用此註釋更新數據庫中的記錄。對話框的評論

我有以下的jQuery函數:

$('.releaseMessage').click(function (evt) { 
    evt.preventDefault(); 
    var msgId = $(this).closest('tr').children().eq(2).html(); 
    var senderBIC = $(this).closest('tr').children().eq(3).html(); 

    var idPredefineDetail = $(this).closest("div").find("input[name=idPredefineDetail]").value(); 



    var _msgId = JSON.stringify({ msgId: msgId, senderBIC: senderBIC }); 
    $("#release-dialog-text").text("You are about to release message ("+ msgId + ")"); 
    $("#release-dialog").dialog({ 
     model: true, 
     buttons: { 
      Ok: function() { 
       $(this).dialog("close"); 
       $.ajax({ 
        type: "POST", 
        url: "Default.aspx/ReleaseMessage", 
        data: _msgId, 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        success: function() { 
        }, 
        error: function (xml, textStatus, errorThrown) { 
         alert(xml.status + "||" + xml.responseText); 
        } 

       }); 

      }, 
      Cancel: function() { 
       $(this).dialog("close"); 
      } 
     } 
    }); 
}); 

而我在對話框DIV是:

<div id="release-dialog" title="Release Message"> 

    <div id="release-dialog-text"> 

    </div> 
    <input id="comment" type="text" /> 
</div> 
+0

那麼這有什麼問題? – 2013-04-11 10:51:07

+0

你有什麼問題或問題? – Nelson 2013-04-11 10:53:04

+0

正如帖子所述,我需要將正在寫入文本框的評論分配給本地變量。我試過 var strComment = $('release-dialog input')。val(); 和 var strComment = $('#comment')。val() both return no text – CSharpNewBee 2013-04-11 10:59:19

回答

1

確定排序此使用這種方法。

window.parent $( '#release-dialog') .attr('title','Release Message') .html('Enter your comment') .dialog({

     ... rest of dialog stuff 
      var comment = window.parent.$('#releasecomment').val();