While updating, I noticed the new event system. Is there now an event
for when a container has finished updating? Someone on this list
helped me with a "defer" service in AngularJS 0.9.x, but the solution
is broken in 0.10.x, and before trying to fix the old way, I would
like to know if something akin to a $renderComplete callback exists in
the 0.10 branch. For example, I'd like to be able to do something like
the following:
angular.directive("my:cycle", function(expr,el){
return function(container){
this.$on('$renderComplete', function() {
$(container).cycle({ fx: 'fade',
speed: 500,
timeout: 3000,
pause: 1,
next: '#next',
prev: '#prev'});
});
}
});
Thank You,
Daniel
In preparation for incorporating AngularJS into my first production
app, I'm starting to update my AngularJS in Rails demo to AngularJS
0.10.x (Speaking of the demo, thank you Igor for the t-shirts! They
arrived last week).
While updating, I noticed the new event system. Is there now an event
for when a container has finished updating? Someone on this list
helped me with a "defer" service in AngularJS 0.9.x, but the solution
is broken in 0.10.x, and before trying to fix the old way, I would
like to know if something akin to a $renderComplete callback exists in
the 0.10 branch. For example, I'd like to be able to do something like
the following:
angular.directive("my:cycle", function(expr,el){
return function(container){
this.$on('$renderComplete', function() {
$(container).cycle({ fx: 'fade',
speed: 500,
timeout: 3000,
pause: 1,
next: '#next',
prev: '#prev'});
});
}
});
Great! Please use whatever you like. The slides can be downloaded from
here: http://www.slideshare.net/dnelson-cs/javascript-frameworks-for-well-architected-immersive-web-apps-9735260
(these are the re-worked slides from my Bar Camp Nashville
presentation; they don't include some parts from the video--such as
file location within the hierarchy or how to include the CSRF
token--if you want those, let me know, and I'll provide you with those
slides, too).
> There isn't such a thing (yet). What should it do? do you want this code to
> run every time angular finishes rendering the view? More likely you want it
> to run just once when the first compilation/linking is finished.
Given:
Widget:
angular.directive("my:cycle", function(expr,el){
return function(container){
this.$on('$renderComplete', function() {
$(container).cycle({ ... });
});
}
});
And template:
<div id="photos" my:cycle>
<div class="photo" ng:repeat="photo in photos">...</div>
</div>
And controller:
self.photos = Photos.index(...);
Then:
$renderComplete would not fire until the photos data were received and
the .photo divs within the #photos div were fully rendered. If the
data in self.photos were updated, then the $renderComplete event
should fire again after the contents of the #photos div finished
updating to represent the new data in self.photos.
In this particular example, this is necessary because jQuery Cycle
needs to be applied after all the divs are present in the dom, but it
seems like a good general purpose callback to be able to be notified
whenever the dom is updated to reflect data changes.
> can you create a js fiddle if you are still having problems with this?
I'll try to get it working with defer again.
Thank You,
Daniel
angular.directive('my:cycle', function(expr,el){
return function(container){
this.$watch(function() {
if ($(container).children().length) {
$(container).cycle({ fx: 'fade',
speed: 500,
timeout: 3000,
pause: 1,
next: '#next',
prev: '#prev' });
}
});
}
});
Best,
Daniel
Daniel
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Just want to make sure that the $renderComplete conversation (feature
request?) isn't lost. It seems pretty complicated to build such
functionality at this point. I actually had to revert back to my
unoptimized $watch solution for the cycle widget because when I
started running my Rails demo app in production mode, jQuery Cycle
threw an error on the more fleshed out version you provided.
That is, jQuery Cycle threw an error in Rails production environment using this:
https://github.com/centresource/angularjs_rails_demo/blob/de71c15eb508e45c8f955820be4ff4ec37bcda55/app/assets/javascripts/widgets.js
But it didn't throw an error using this:
https://github.com/centresource/angularjs_rails_demo/blob/8c38370dfd1f21764dfb20c25c92384d48379390/app/assets/javascripts/widgets.js
It would be awesome if we could do the following and know that the
$renderComplete function would fire once each time the contents of
"container" were updated:
angular.directive("my:cycle", function(expr,el){
return function(container){
this.$on('$renderComplete', function() {
$(container).cycle({ fx: 'fade',
speed: 500,
timeout: 3000,
pause: 1,
next: '#next',
prev: '#prev'});
});
}
});
Thank You,
Daniel
Thank You,
Daniel
Cannot read property 'cycleW' of undefined. It seems specific to
jQuery cycle, but is hard to debug because it arises in production
only, which is when source code has been obfuscated.
Yes, but it only happens when in production, so it is hard to figure
out why (especially since your solution appears to prevent itself from
being called when the container has no children).
Thanks,
Daniel