2

私はjquery UIダイアログボックスを作成しましたが、機能しますが、ボタンのタグ(名前)の値をjqueryに渡す必要がありますが、さまざまなことを探して試してみましたが、何もしませんでした:(

私が得たもの:

タグ (PHP によって埋められた値):

<a href="#" class="name">'.$name.'</a>

HTML div:

<div id="name" title="view or send this user a message?"></div>

jquery:

$(document).ready(function() {
  $(function() {
    $( "#name" ).dialog({
      autoOpen: false,
      width: 500,
      show: {
        effect: "fold",
        duration: 500
      },
      hide: {
        effect: "explode",
        duration: 500
      },
      buttons: {
                    //Names need to go here as part of the buttons
        "Send " + $(this).data('name') + " a message": function() {
          $( this ).dialog( "close" );
        },
        "view " + $(this).data('name') + "profile ": function() {
          $( this ).dialog( "close" );
        }
      }
    });

    $( "a.name" ).click(function() {
    //Pass name to form
    $("#name").data('name', $("a#name").text());
    $( "#name" ).dialog( "open" );
  });
});

});

そのため、a#name から名前を取得する必要があり、.text() を試しました。ボタンに使用するjqueryに。

助けてくれてありがとう:)

4

2 に答える 2