初始化zurb基金会与angularjs提示 [英] Initializing zurb foundation's tooltip with angularjs
问题描述
我做了的$(document).foundation()
火 viewContentLoaded
,但由于某种原因,它仍不运行:
I've made $(document).foundation()
fire on viewContentLoaded
but for some reason it still does not run:
var myApp = angular.module("myApp", []).run(function($rootScope) {
$rootScope.$on('$viewContentLoaded', function () {
console.log('loaded!');
$(document).foundation();
});
});
在这里观看演示: http://jsfiddle.net/UpwvU/
我跟着几个答案来自这个问题但他们都不让我成功的。
I've followed several answers from this question but none of them made me succeed.
推荐答案
$ viewContentLoaded
听起来像是一个简单的事件....但不幸的是,这并不意味着所有的在DOM元素已经呈现。不幸的是角的方式做了很多次消化这几乎是不可能为它definitvely说全部完成
$viewContentLoaded
sounds like a simple event.... but unfortunately it doesn't mean all of the DOM elements have been rendered. Unfortunately the way angular does many digest cycles it's nearly impossible for it to definitvely say ALL DONE
要证明这一点尝试以下操作:
To prove this try following:
.run(function($rootScope, $timeout) {
$rootScope.$on('$viewContentLoaded', function () {
console.log('loaded!');
console.log($('.has-tip').length,' Num tips');// likely zero as ng-repeat hasn't completed
$timeout(function(){
console.log($('.has-tip').length,' Num tips after timeout'); // 5
},300)
});
});
放入 $超时块你的基础code
键,看看是否有帮助。至于时间等待....不知道什么最好的建议是
Put your foundation code in $timeout block
and see if that helps. As for duration to wait.... not sure what best suggestion is
<大骨节病> 与$超时演示 骨节病>
这篇关于初始化zurb基金会与angularjs提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!