2014-01-15 129 views
1

我在http://feedthefire.in和Firebase dot com上設置並註冊了帳戶,以管理我願意在我的網站上展示的Feed。我將所有內容都設置好了,並將提要拉到Firebase中,就像它現在應該加入到Firebase一樣,現在是時候將其添加到網頁中了......沒有什麼,無法從Firebase中獲取提要。我在標題中加入firebase.js參考和身體,我把將Firebase VAR添加到網站

<script type="text/javascript"> 
    var ref = new Firebase"'https://aodf.firebaseio.com"); 
    ref.child("meta").once("value", function(snapshot) { 
     $("#e-title").html(snapshot.val().description); 
    }); 
    ref.child("articles").limit(3).on("child_added", function(snapshot) { 
     var article = snapshot.val(); 
     var link = $("<a>", { 
      "href": article.link, 
      "target": "_blank" 
     }); 
     $("#e-list").append($("<li>").append(link.html(article.title))); 
    }); 

當你去http://sandbox.studiorooster.com/ao我應該看到提要列表,但是我沒有,所以我知道我我應該在代碼中放置其他的東西;我覺得:)

回答

2

有在你上面貼東西存在的一些問題,下面的每一個解釋:

    上線#2
  1. 語法錯誤:var ref = new Firebase("https://aodf.firebaseio.com");
  2. 你加載描述在#3-5行,但從來沒有渲染它,因爲在鏈接到的頁面中沒有編號爲e-title的元素。試着將<h2 id="e-title"></h2>添加到您的模板。
  3. 同樣,您正在第6-13行加載大量文章,並嘗試將這些項目中的每一個追加到列表中,其編號爲e-list,這在您的模板中也不存在。嘗試將<ul id="e-list"></ul>添加到您的模板中。

希望有所幫助!

+0

感謝羅布。我按照建議進行了修改,但仍然無法解決任何問題。還有其他想法?再比你一次。 –

+0

看着[http://sandbox.studiorooster.com/ao/](http://sandbox.studiorooster.com/ao/),你仍然在這裏有一個語法錯誤:'var ref = new Firebase「https:/ /aodf.firebaseio.com「);'應該是'var ref = new Firebase(」https://aodf.firebaseio.com「);'。 –

+0

我推薦閱讀[Google Chrome DevTools](https://developers.google.com/chrome-developer-tools/docs/console)以瞭解如何使用瀏覽器工具來追蹤這些問題。 –