私はノックアウトjsが初めてで、あなたに非常に基本的な質問があります:
画面上の twitter ハンドルを変更するユーザーを正常にサブスクライブし、ツイートを正常にフェッチして、ユーザーの最後の最近のツイートを表示することができましconsole.log(json.results[0].text);
たjson.results
:空の配列recent_tweets.push(json.results[0].text)
が表示されます。[]
何が起こっている?ko.observable 配列のロギングは可能ですか?
console.log("TwitterFeedComponent loaded")
TwitterFeedComponent = function(attributes) {
if (arguments[0] === inheriting)
return;
console.log("TwitterFeedComponent() loaded")
var component = this;
var url = 'https://twitter.com/search.json?callback=?';
this.attributes.twitter_user_handle.subscribe(function(value) {
alert("the new value of the twitter handle is " + value);
console.log("I have loaded")
var url = 'https://twitter.com/search.json?callback=?';
var twitter_parameters = {
include_entities: true,
include_rts: true,
q: 'from:' + value,
count: '3'
}
$.getJSON(url,twitter_parameters,
function(json) {
result = json.results[0].text
recent_tweets.push(json.results[0].text);
console.log(recent_tweets);
console.log(json.results[0].text);
});
});
};