0

我想为几个不同的按钮打开我的 Jquery 对话框。我有一个在点击时调用的 facebook ui 提要(我希望在对话框中有它,但那是另一回事了)。它只打开一个按钮(出现在我的 html 中的第一个按钮)。这是代码:

<script>
$(function() {
  $( "#dialog-modal" ).dialog({autoOpen: false, resizable: false, draggable: false, height: 250, width: 500, modal: true, dialogCLass: 'main-dialog-class'});

  $( "#opener" ).click(function() {
                       $( "#dialog-modal" ).dialog( "open" );

                       $.getJSON(
                                 "/like_artist.php", // The server URL
                                 { artist_id : $(this).data('artist_id') }, // Data you want to pass to the server.
                                 function(json) {

                                 var artist = json[1];

                                    var text = '';
                                    text = ' ' +  artist ;


                                    FB.ui({
                                    method: 'feed',
                                   // redirect_uri: '/index.php',
                                    link: 'WEBPAGE',
                                    name: '',
                                    caption: '',
                                    description: ''

                                    });


                                    $('#dialog-modal').text(text);

                                    alert(artist);
                                 }// The function to call on completion.
                                 );

        });

  });

</script>

按钮:

<button type="button" id="opener" data-artist_id="3">Play My City</button>

<button type="button" id="opener" data-artist_id="4">Play My City</button>

<button type="button" id="opener" data-artist_id="2">Play My City</button>

ETC...

谢谢您的帮助!

4

1 回答 1

0

全部更改id="opener"class="opener"

然后将您的 js 更改$( "#opener" ).click$( ".opener" ).click

于 2013-02-22T23:22:00.960 回答