嘿,夥計們想知道,如果你能幫助我,請..我在此還是很新的,但我試着進入jQuery Mobile的。jQuery Mobile的,Twitter搜索裝載
我的應用程序的這一部分(只是爲了測試的東西出來)是一種基於點擊1 2的按鈕加載不同的Twitter搜索查詢。因此,爲了改變查詢,我正在考慮傳遞數據標識文本並將它與其餘的搜索字符串連接起來。
所以我開了一個頭,我想我知道我錯了,但我不知道如何去這樣做的權利真的!所以,任何幫助,將不勝感激請。
本質上我認爲會出錯的是,twitter搜索會立即加載到頁面中,但我的字符串只在用戶單擊按鈕(其上有twitterlink類)後纔會傳遞。因此,首先我不能讓變量傳出,但其次,因爲url:未被填充,所以不會加載推文。
所以,當我硬編碼// VAR URL = 'http://search.twitter.com/search.json?q=from:irishhockey';它的工作原理,但盛大要做的只是不此刻
var twitId;
var url;
$(function(){
//this part is to grab the data-identity string in
$('.twitterlink').live('click',
function() {
twitId = $(this).data("identity");
//this was to concatenate the first part of the string with the twitId (data-identity)
url = 'http://search.twitter.com/search.json?q=from:' + twitId ;
}
);
//with the below hardcoded line uncommented it brings tweets in fine
//var url = 'http://search.twitter.com/search.json?q=from:irishhockey';
$.ajax({
url: url,
dataType: 'jsonp',
success: function(json_results){
console.log(json_results);
// Need to add UL on AJAX call or formatting of userlist is not displayed
$('#twitList').append('<ul data-role="listview"></ul>');
listItems = $('#twitList').find('ul');
$.each(json_results.results, function(key) {
html = '<img src="'+json_results.results[key].profile_image_url+'"/>';
html += '<h3><a href="#">'+json_results.results[key].text+'</a></h3>';
html += '<p>From: '+json_results.results[key].from_user+' Created: '+json_results.results[key].created_at+'</p>';
listItems.append('<li>'+html+'</li>');
});
// Need to refresh list after AJAX call
$('#twitList ul').listview();
}
})
})
我試圖把它全部倒入點擊功能藏漢工作對我來說可變填充anykind,希望它沒有火過阿賈克斯的東西immeadiately,但這並不適用於我。
我知道我可能只是接近這在錯誤的方式,但我只是不知道我應該在它該走什麼樣的方式,所以我說..所有的幫助是值得歡迎,並感謝一百萬你的時間。