私はknockoutjsの新人です。私はあなたのための基本的な質問があります:KO観測可能な配列を記録することは可能ですか?
オンスクリーントゥウィッターハンドルを変更したユーザーにサブスクリプションを行い、つぶやきを正常に取得して最後の最近のつぶやきを表示できましたconsole.log(json.results[0].text);
を使用しているユーザしかし、json.results
を最近のつぶやきにプッシュすると、観測可能なアレイが動作しているとは確信していません。 []
空の配列があります。
何が起こっていますか? 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);
});
});
};
'console.log(recent_tweets())'のような基本配列をログに記録する必要があります。 –