2013-03-29 74 views
2

我在單頁Backbone應用程序的登錄頁面上使用Twitter嵌入式時間軸小部件。當用戶登錄時,我通過Backbone routing更改頁面,並且Twitter小部件不再顯示。但是,如果您查看瀏覽器開發人員工具的「網絡」面板,則會每隔15秒左右向http://syndication.twimg.com/widgets/timelines/paged/發送一次請求。 如何阻止這些請求?如何停止來自輪詢的Twitter時間軸小部件?

如果我delete window.twittr,我得到6「未捕獲的ReferenceError:twttr沒有定義」錯誤從超時回調...它工作,但似乎不是很乾淨。 有沒有更好的方法?

+0

看看我對以下問題的回答。 http://stackoverflow.com/questions/19842919/how-to-setup-the-timeout-before-a-refresh-on-twitter-embedded-timelines/19843648#19843648 – Trevor

回答

0

我相信設置Tweet limit可能是一個選項。

資料Tweet極限:To fix the size of a timeline to a preset number of Tweets, use the數據鳴叫極限=「5」屬性with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling.由於插件是固定尺寸的,也不會更新使用此選項時輪詢。

https://dev.twitter.com/docs/embedded-timelines

例如

<a class="twitter-timeline" href="https://twitter.com/twitterapi" data-widget-id="YOUR-WIDGET-ID-HERE" data-chrome="nofooter" data-tweet-limit="3">Tweets by @twitterapi</a>

,並根據需要,你可以手動更新您的窗口小部件,將其取出即可重新插入HTML然後調用。

twttr.widgets.load()

相關問題