0

我在 JqueryUI 中使用手风琴功能。在每个项目中都有一个带有名称的提交按钮。名称是我在对话窗口中需要的 id。当我单击提交按钮时,使用此功能

$( ".opener" ).click(function() {
        console.log( $(this).attr("name"));
      $( "#dialog-confirm" ).dialog( "open" );
    });

在我的控制台日志中,我现在看到了正确的 ID。但是在对话框窗口中我无法获取此 ID。这是对话窗口

  $(function() {
  $( "#dialog-confirm" ).dialog({
      autoOpen: false,
  show: {
    effect: "fade",
    duration: 500
  },
  hide: {
    effect: "fade",
    duration: 200
  },
  resizable: false,
  height:180,
  modal: true,
  buttons: {
    "Aannemen": function() {
      $( this ).dialog( "close" );
      alert('ID IS');       << this is where i want the id
    },
    Cancel: function() {
      $( this ).dialog( "close" );
    }
  }
});

那么我怎样才能在脚本的这个位置获得 id: alert('ID IS');

4

1 回答 1

1
var name;
$( ".opener" ).click(function() {
        name =$(this).attr("name");
      $( "#dialog-confirm" ).dialog( "open" );
});

$(function() {
  $( "#dialog-confirm" ).dialog({
      autoOpen: false,
  show: {
    effect: "fade",
    duration: 500
  },
  hide: {
    effect: "fade",
    duration: 200
  },
  resizable: false,
  height:180,
  modal: true,
  buttons: {
    "Aannemen": function() {
      $( this ).dialog( "close" );
      alert(name);       << this is where you get the id
    },
    Cancel: function() {
      $( this ).dialog( "close" );
    }
  }
});
于 2013-04-10T12:00:15.630 回答