-1

jsfiddle の作成物を自分の Web サイトに転送しようとしていますが、転送できません。ここにそれへのリンクがあります:

http://jsfiddle.net/mDc7p/213/

/* 
    Eventbrite Examples - organizer event list

    If you copy this code, please set your own API Key in the example below.
    You can request one here: http://www.eventbrite.com/api/key
*/

Eventbrite({'app_key': "HSMTSI2CUDKAXFTXX2"}, function(eb){

    // define a few parameters to pass to the API
    // Options are listed here: http://developer.eventbrite.com/doc/organizers/organizer_list_events/
    var options = {
        'id'    : "1667880002"
    };

    // provide a callback to display the response data:
    eb.organizer_list_events( options, function( response ){
        $('.event_list').html(eb.utils.eventList( response, eb.utils.eventListRow ));
    });
});

タグ内で閉じられたjavascriptコード<script type="text/javascript"></script>をheader.php、footer.php、およびテンプレートファイルの下部に追加しようとしました(その特定のページで使用しているものですが、機能していません.javascriptコードを追加した後、<div class="event_list"></div>コードを機能させたい場所であるため、ページコンテンツ領域内に追加しますが、機能していません.「head」タグ内のheader.phpファイルにjqueryライブラリを含めています.また、追加してonLoadメソッドを試しました.コードを JavaScript の先頭に追加しましたが、残念ながらうまくいきませんでした。

PS私のウェブサイトはWordpressを実行しています。

4

2 に答える 2

2

document.ready でラップしましたか? jQuery は、ロード時に存在しない要素には作用しません。

$(document).ready(function() {
    ...
});

または省略形

$(function() {
    ...
});
于 2013-03-18T16:29:05.800 に答える
2

コードがDOM Readyで実行されるようにフィドルが設定されています。そのため、JavaScript セクションのコードを onready 呼び出しでラップする必要があります。

<script>
$(function() {

    /* 
        Eventbrite Examples - organizer event list

        If you copy this code, please set your own API Key in the example below.
        You can request one here: http://www.eventbrite.com/api/key
    */

    Eventbrite({'app_key': "HSMTSI2CUDKAXFTXX2"}, function(eb){

        // define a few parameters to pass to the API
        // Options are listed here: http://developer.eventbrite.com/doc/organizers/organizer_list_events/
        var options = {
            'id'    : "1667880002"
        };

        // provide a callback to display the response data:
        eb.organizer_list_events( options, function( response ){
            $('.event_list').html(eb.utils.eventList( response, eb.utils.eventListRow ));
        });
    }

);    
});
</script>
于 2013-03-18T16:29:36.500 に答える