可能angular.js导致另一个jQuery插件不火,并在控制台中产生任何错误? [英] Could angular.js cause another jQuery plugin not to fire and produce no errors in the console?
问题描述
下面是分期网站的链接。
和下面是怎样的剧本被标记的在我的HTML。
<脚本SRC =HTTP://$c$c.jquery.com/jquery-1.11.0.min.js>< / SCRIPT>
&所述; SCRIPT SRC =http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js>&下; /脚本>
<脚本>
变量$ J = jQuery.noConflict();附加$ J(函数(){
附加$ J('#集装箱')mixItUp()。});
< / SCRIPT>
<脚本SRC =JS / app.js>< / SCRIPT>
更新2014年11月18日
新的HTML标记
< DIV混合它向上ID =容器类=容器>
&所述;股利类=混合类-1数据myorder =1>&下; / DIV>
< DIV CLASS =混合类-1数据myorder =2>< / DIV>
< DIV CLASS =混合类-1数据myorder =3>< / DIV>
< DIV CLASS =混合类-2的数据myorder =4>< / DIV>
< DIV CLASS =混合类-1数据myorder =5>< / DIV>
< DIV CLASS =混合类-1数据myorder =6>< / DIV>
< DIV CLASS =混合类-2的数据myorder =7>< / DIV>
< DIV CLASS =混合类-2的数据myorder =8>< / DIV> < DIV CLASS =差距>< / DIV>
< DIV CLASS =差距>< / DIV>
< / DIV>
这是因为你的脚本来启动MixItUp在 #container的
你的<$ C $的内容之前运行C> NG-视图有机会来呈现,所以用容器的标识元素不会在DOM存在。
这是你别无选择,只能做的事情的角路从一开始去的指令,即
HTML
&LT; DIV混合它向上ID =容器类=容器&GT;&LT; / DIV&GT;
JS
.directive('mixItUp',函数(){
var命令= {
限制:'A',
链接:链接
}; 返回指令; 功能链接(范围,元素,ATTRS){
$(元件).mixItUp();
}
});
Because time is a factor I won’t be able to install MixItUp.js in my project “the angular way.” That being said, I am just hooking it up like the documentation on the getting started page states; Just a pure vanilla jQuery installation. But alas, nothing. Not even an error in the console. I am wondering what can I be doing wrong?
Here is a link to the staging site.
And below is how the scripts are being marked-up in my HTML.
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js"></script>
<script>
var $j = jQuery.noConflict();
$j(function() {
$j('#Container').mixItUp();
});
</script>
<script src="js/app.js"></script>
UPDATE 11.18.2014
NEW HTML MARKUP
<div mix-it-up id="Container" class="container">
<div class="mix category-1" data-myorder="1"></div>
<div class="mix category-1" data-myorder="2"></div>
<div class="mix category-1" data-myorder="3"></div>
<div class="mix category-2" data-myorder="4"></div>
<div class="mix category-1" data-myorder="5"></div>
<div class="mix category-1" data-myorder="6"></div>
<div class="mix category-2" data-myorder="7"></div>
<div class="mix category-2" data-myorder="8"></div>
<div class="gap"></div>
<div class="gap"></div>
</div>
That's because your script to initiate MixItUp on #container
runs before the contents of your ng-view
has had a chance to render, so an element with an id of container does not yet exist in the DOM.
This is where you have little choice but to do things "the Angular way" from the get go with directives, i.e.
HTML
<div mix-it-up id="Container" class="container"></div>
JS
.directive('mixItUp', function () {
var directive = {
restrict: 'A',
link: link
};
return directive;
function link (scope, element, attrs) {
$(element).mixItUp();
}
});
这篇关于可能angular.js导致另一个jQuery插件不火,并在控制台中产生任何错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!