リスト アイテムのタップ イベントによってトリガーされる (Google Feeds API を使用した) フィード アイテムのリストの生成に問題があります。ページの読み込み時に関数を呼び出すことができ、うまく機能します。ただし、「タップ」イベントで関数を呼び出そうとすると、空白のページが生成されます。
イベントをトリガーしたいリスト項目は次のとおりです(「タップ」イベントを呼び出しています):
<li id="welstech" class="listFeeds">
<a href="#">
<img src="_images/welstech-logo-db.jpg" alt="WELSTech" />
<h2>WELSTech Podcast</h2>
<p>Discussions about Tech & Ministry</p>
</a>
</li>
HTMLページの下部に配置したスクリプトは次のとおりです。
<script type="text/javascript>
$(document).on('tap', '.listFeeds', function() {
listAudioPosts("http://feeds.feedburner.com/welstech");
});
</script>
呼び出す関数は次のとおりです。
function listAudioPosts(feedurl){
google.load("feeds", "1");
console.log("I'm still going 1");
function initialize() {
console.log("I'm still going 2");
var feed = new google.feeds.Feed(feedurl);
feed.setNumEntries(10)
var output = '<ul data-role="listview" data-split-icon="info">';
var name = "welstech";
feed.load(function(result) {
if (!result.error) {
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var mediaGroups = result.feed.entries[i].mediaGroups[0].contents[0];
var stripContentSnippet = entry.contentSnippet.replace(/[^a-zA-Z 0-9.:-]+/g,'');
var stripaContentSnippet = stripContentSnippet.replace('lt--pagingfilter--gt','');
output += '<li>';
output += '<a href="#">';
output += '<h2>' + entry.title + '</h2>';
output += '<p>' + stripaContentSnippet + '</p>';
output += '</a>';
output += '</li>';
} // loop through all the feeds and create li elements
} // end of if statement
output += '</ul>';
$("#testtouchoutput").html(output).trigger('refresh');
$.mobile.changePage("#test");
}); // end feed.load (function(result)
} // end initialize function
google.setOnLoadCallback(initialize);
}
以下を参照して、htmlページの下部にあるこのスクリプトを使用して、ページの読み込み時に関数を呼び出すことができるため、関数が機能することはわかっています。また、そのサブ関数の前に console.log 出力が表示されますが、その後の出力は表示されないため、関数がサブ関数 initialize() まで到達することもわかっています。
<script type="text/javascript">
listAudioPosts("http://feeds.feedburner.com/welstech");
</script>
したがって、ホームページが読み込まれると、関数が実行され、生成したいリストにページが更新されます...「タップ」イベントで生成したい場合を除きます。
私はかなり新しいjqueryプログラマーなので、それは明らかなことだと確信しています。私は何が欠けていますか?
ありがとう。