javascript - Firebase events not triggered properly when joining tables with Firebase-util -


I am using the intersection function of Firebase-util to find all the comments for a given link. This works best for the first time when I call, but when I extract the contents of the database and change it again, it does not correctlyify my callback value until the processing path remains the same Until then, what references do not work?

Run this example. When you click the button, it erases and recreates the data. As you can see, the comment list is not redone after the data is rebuilt.

 
& lt; link rel = "import" href = "https: //www.polymer- project.org/components/polymer/polymer.html"> & Lt; Script src = "http://cdn.firebase.com/v0/firebase.js" & gt; & Lt; / Script & gt; & Lt; script src = "https://cdn.firebase.com/libs/firebase-util/0.1.0/firebase-util.min.js" & gt; & Lt; / Script & gt; & Lt; Polymer-element name = "my-element" & gt; & Lt; Templates & gt; & Lt; H1 & gt; Test of Firebase-Use Inertia & lt; / H1> & Lt; Div & gt; & Lt; Click on the button = {{initializeFirebase}} & gt; Reset data & lt; / Button & gt; & Lt; / Div & gt; & Lt; Ul & gt; & Lt; Repeat template = "{{original comment in comment]}" & gt; & Lt; Li & gt; {{rootComment.comment.content}} & lt; UL & gt; & Lt; Template repeat = "{{sub comment in rootcomment.children}}" & gt; & Lt; Li & gt; {{subComment.comment.content}} & lt; UL & gt; & Lt; Repeat template = "{{sub topic comment in all comments}}" & gt; & Lt; Li & gt; {{SubSubComment.comment.content}} & lt; / li & gt; & Lt; / Template & gt; & Lt; / Ul & gt; & Lt; / li & gt; & Lt; / Template & gt; & Lt; / Ul & gt; & Lt; / li & gt; & Lt; / Template & gt; & Lt; / Ul & gt; & Lt; / Template & gt; & Lt; Script & gt; Polymer ('my-element', {ready: function ()} {var sanitizeUrl = function (url) {return encodeurIComponent (url) .replace (/. / G, '% zZ');}; var baseUrl = "https : //nested-comments-test.firebaseio.com "; var linkUrl = baseUrl + '/ links /' + sanitizeUrl (document.URL) + '/ comments'; var annotations url = base url + '/ comments'; var root = New Firebase (Base URL); ThisInriseel Refresh = Function () {Function AdLink (URL, Callback) {var of = Syntax URL (URL), New links = {URL: url, created at: firebase.SRVire VLETMMP} root '/ Link / '+ key) .Up Magistrate (New link); Callback (key);} function addComment (attributes, callback) {return root.child ('/ comments'). Push (attributes, callback);} CommentAdded (Attribute [newCommentId] = true; root; {newcommentId} = true; root; {newcommentId = childSnapshot.name}, attributes = {}, link = childSnapshot.val () in the function. Link, url = '/ links /' + link + '/ comments' .child (url) .update (attributes);} root.remove (function () {root.child ('/ comments'). ('Child_added' , Comment added on); AddLink (document.URL, function) {var attributes = {link: link, content: "this is the first comment."}, First comment, second comment ID; first comment = add comment ( Attributes) .name (); attributes = {link: link, content: "this is the first answer "Answer: Commentation: First commentind}; Second commentation = addcomment (attributes) .name (); attributes = {link: link, content:" This is the second answer. ", Answerotainment: Second Comment ID; At Commute (Attributes) ; Attributes = {link: link, content: "This is the second answer before.", Answer commentation: first comment}; AddComment (attributes);});});}; this.initializeFirebase (); Var findChildrenForComment = function (snapshot, parent comment) {var returnVal = []; Snapshot.forEach (function (snap) {var comment = snap.val (), commentId = snap.name (); if (comment.replyToCommentId === parentCommentId) {var children = findChildrenForComment (snapshot, comment id); var obj = {CommentId: commentId, comment: comment, parentId: parentCommentId}; if (children.length) {obj.children = kids;} returnVal.push (obj);}}); Withdrawal return; }; This.ref = Firebase.util.intersection (new firebase (link URL), new firebase (comments url)); This.comments = {}; Var = this; This.ref.on ('value', function (snapshot) {that.comments = findChildrenForComment (snapshot);}); }}); & Lt; / Script & gt; & Lt; / Polymer element & gt; & Lt; My-element & gt; & Lt; / My-element & gt;

Completely removed from a path There are all the reasons for canceling all callbacks in a way. The solution to this behavior is to remove the children at one time instead of removing their parents' path.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -