getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

jquery ready, load events never fire using promises #66

Closed NiQ-B closed 11 years ago

NiQ-B commented 11 years ago

I am hoping this is a user issue. I am building an application that requires the domready event to fire. Using $().ready from the jquery library for the call back. When I use epf.io to pull data via the back end the $(window).load() event nor the $().ready event fires. If I load the same request from the server using jquery.ajax the page loads fine. Really liking epf and would like to continue using it but I need the those other libraries also. The route is not dynamic, data loads fine either way. If I comment out the route ready completes if I use the ajax call ready event fires.

Works:

App.AccountRoute = Em.Route.extend({ model: function(params) { var account; account = Em.ObjectProxy.create(); return $.ajax({ type: "GET", url: 'api/v1/accounts/2', async: false, dataType: "json", success: function(data) { return account.set('content', data); } }); } });

Page never fires $(window).load or $().ready:

App.AccountRoute = Em.Route.extend({ model: function(params) { var account; return account = this.session.load('account', 2); } });

Thank you for your time and the lib

lastobelus commented 11 years ago

have you tried manually firing the event in the then?

this.session.load('account', 2).then(function(obj){ $(window).load(obj); });

ghempton commented 11 years ago

I can't imagine how this is EPF related. Can you try turning on "break on all exceptions" in the chrome developer tools and see if there is an error?

NiQ-B commented 11 years ago

Ok for the record I tried a lot of things "then" which is what I think you meant being one of them. On the Router (beforeModel, afterModel, ajaxStop, ajaxComplete, activate, deactivate...) On the view didInsertElement which is what was working prior to loading models with epf (afterRender) a dozen or so permutations of Em.run which allowed me to open a debug session inside of the .load call back issued ajaxStops inside that callback so on and so on. Honestly don't think this is an epf issue so I will close the issue. I did turn on break on all errors in chrome and it showed no errors in my code. The only error I received was Rails was loading a different version of jquery prior to the version I was loading :-). The issue really looks like a Router issue with the face lift. It looks as though as long as my initial page load doesn't issue any promises which is why the raw ajax seems to work the page loads fine. If the initial page transitions on boot and receives a promise even if the data returns quickly domReady or load callbacks don't fire. Thanks for the suggestions if you think of more I will relook at it. My work around is to not load any data on the initial page load and wait for the domready to complete then transitionTo a route on user interaction.