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 に答える