Twitter の検索結果のスクロール リストを持つページを作成しようとしています (jQuery の twitter.search を使用)。ユーザーはボタンをクリックして検索語を変更できる必要があります (したがって、「Apple」をクリックすると検索語が「Apple」に変更されます。
変数を使用して検索語を設定しています。その変数をテキスト文字列 (つまり、searchText = "Pineapple";) に設定すると機能します。しかし、ボタンを使用して変数を変更しようとしても、何も起こりません。
//編集 - ボタンは変数を変更していないようです。考え?ありがとう。
<script type="text/javascript">
//set default value for searchText
searchText = "Pineapple";
//this sets up our Twitter stream
$(document).ready(function() {
$('#twitter-stream').twitterSearch({
term: searchText,
// no fade
animOut: { opacity: 1 },
avatar: false,
anchors: false,
bird: false,
colorExterior: 'white',
colorInterior: 'white',
pause: true,
time: false,
timeout: 2000
});
});
</script>
<script type="text/javascript">
$("#button-container").on("button", "click", function( e ) {
searchText = $(this).text();
});
</script>
<div id="twitter-stream" title="Mouse away to un-pause">
</div>
<div id="button-container">
<button class="button"> Apple </button>
</div>
<button onclick="alert(searchText);">Click me!
</button>