0

我需要从此 js 代码访问表单数据中名为“partnerId”的隐藏字段:

$(document).ready(function() {
  showPartnerSettings = function(e) {
    e.preventDefault();

    var $dialogForm = $("<div />")
    .attr("id", "partner-settings-form")
    .append($loading.clone())
    .load(envPath + "/partner/settings?partnerid="+e.data.partnerId, null, function(){ $("#partner-settings-form").css("display", "block"); })
    .dialog({
      title: "Partner Settings",
      modal: false, 
      resizable: false,
      width: 580, //CPB 04.11.13
      position:['middle',130],
      "close" : function(){ 
        var dialogid=$(this).parent("div").attr("id");
        $("#Tabs ul li."+dialogid).remove();
        $(this).remove();
        $("#alertmod").remove();
        //$link.removeClass('preventclick');
      },
    })        
    .dialog("open")
    .css("display", "block");

    return false;
  };

有没有办法从传递给的事件对象中检索这个值showPartnerSettings()

4

1 回答 1

0

在它被加载到 DOM之后,您将需要访问它。

var $dialogForm = $("<div />")
    .attr("id", "partner-settings-form")
    .append($loading.clone())
    .load(envPath + "/partner/settings?partnerid="+e.data.partnerId,
          null,
          function(){
              /* access field here ... */
              var field = $('#partnerId');

              $("#partner-settings-form").css("display", "block");
          }
     ).dialog({
      title: "Partner Settings",
      modal: false, 
      resizable: false,
      width: 580, //CPB 04.11.13
      position:['middle',130],
      "close" : function(){ 
        var dialogid=$(this).parent("div").attr("id");
        $("#Tabs ul li."+dialogid).remove();
        $(this).remove();
        $("#alertmod").remove();
        //$link.removeClass('preventclick');
      },
    })        
    .dialog("open")
    .css("display", "block");
于 2013-05-13T22:36:02.460 回答