0

クラスのクリック イベントにバインドしようとしていますが、引き続きこのエラーが発生します。

Uncaught SyntaxError: Unexpected token ; 

私のjqueryとHTML

function loadData() {

  isLoading = true;
  $('#loaderCircle').show();

  $.post(apiURL, { f: 'gridview', start: pgStart, end: pgEnd, params: $("#search_basic_form_id").serialize() }, function(data){
        if (data.success) {
            // Create HTML for the images.
            var html = '';

            $.each(data.profiles, function() {

                html += '<li><div class="image-wrapper">';
                html += '<div class="image-options">';
                html += '<a href="#" id="imgoption_'+this.user_id+'" class="favoriteButton" title="Add Favorite"><br>Favorite</a>';
                html += '</div>';
                html += '<a href="/view_profile.php?id='+this.user_id+'">';
                html += '<img src="'+this.file_name+'" width=200px; height="'+this.height+'px" style="border:0;">';
                html += '</a>';

                // Image title.
                html += '<p>'+this.name+' '+this.age+'</p>';
                html += '<p>'+this.city+', '+this.state+'</p>';
                html += '</div>';
                html += '</li>';                    
            });

            // Add image HTML to the page.
            $('#tiles').append(html);

            // Apply layout.
            applyLayout();

            pgStart = data.start;
            pgEnd = data.end;

        }
    }, "json");
};

$(document).ready(function() {

    // Load first data from the API.
    loadData();

    $('.favoriteButton').on('click', function(e) {
        e.preventDefault();

        alert("Favorite Clicked");
    });
...

このエラーが発生する理由はわかりませんが、jquery 呼び出しの最後のセミコロンを指しています。

4

1 に答える 1

4

ああ、思いついた。ドキュメントの準備ができている場合は、これを試してください。

$(document).ready(function() {

違いは新品の欠品です。

于 2012-08-10T20:27:07.497 に答える