YahooArchive / mojito

[archiving soon] Yahoo! Mojito Framework
BSD 3-Clause "New" or "Revised" License
1.57k stars 214 forks source link

Problems with mojitProxy.refreshView() #847

Open ItsAsbreuk opened 11 years ago

ItsAsbreuk commented 11 years ago

Hi,

I experience quite some problems with mojitProxy.refreshView(). It's hard to specify where exactly, because the projects become quite big and a lot of stuff is new to me.

I tried to strip it down where I could and I have 3 issues I would like to mention:

1) version 0.5.0pr4 and 0.5.0 (not before) throw an error when I call mojitProxy.refreshView(myOptions). I see the serverresponse coming in with correct JSON-data, but firebug sais: TypeError: t is null within http://yui.yahooapis.com/3.7.3/build/node-core/node-core-min.js at part uniqueID?"uniqueID":"_yuid",r;this.purge(),this.unplug&&this.unplug(),this.clearData(),t&&e.NodeList.each(this.all("*") Reinstalling 0.5.0pr3 made the error disappear.

2) I'm using composite Mojits, where I refresh the masterMojit. I'm still busy to figure out what goes wrong here, but it seems it has to do with me binding stuff in childmojits, where as after being refreshed the Mojitnodes get a new id. I am unbinding and rebinding to the new child-mojit-nodes, but somehow references are being kept to node-id's that don't exists anymore after a refresh.

3) I created a mastermojit with childmojits, but the visitor should not see the contents of the cildmojits before passing a login. So, I created the view of the mastermojit with handlebars where an {{#if}} statement doesn't render the childmojits at first visit, but a loginscreen instead. After entering logindata, the mastermojit does a refreshView(logindata) and when correct login, the handlebarview renders all childmojits. This doesn't seem to work, because on the client side, I am missing a lot of stuff of the childmojits after correct login.

Do you experience problems of the same? I'm about to stop using refreshView() because it is extremely frustrating. But on the other hand, refreshView can/should be one of the great features of Mojito.

Sorry I can't give more details about the second issue, like said: I'm still figuring out what is happening here.

Marco.

add0n commented 11 years ago

At a minimum, issue #2 should be fixed via this PR:

https://github.com/yahoo/mojito/pull/845

which will be available in 0.5.1

Cheers,

ItsAsbreuk commented 11 years ago

@Bill, Thanks. That would be issue #1 I quess.

I'm not the one to suggest about the right structure to follow, but can't the node's Id being kept the same after a refreshView()?

I found issue #2 has to do with intermojit-communication: I broadcast an event at the masterMojit to the receiverMojit. Now, when the receiverMojit gets refreshed, the masterMojit is broadcasting to the wrong target.

Marco.